Home | History | Annotate | Download | only in SimplifyCFG
      1 ; RUN: opt -simplifycfg -S < %s | FileCheck %s
      2 
      3 ; This load is safe to speculate, as it's from a safe offset
      4 ; within an alloca.
      5 
      6 ; CHECK-LABEL: @yes(
      7 ; CHECK-NOT: br
      8 
      9 define void @yes(i1 %c) nounwind {
     10 entry:
     11   %a = alloca [4 x i64*], align 8
     12   %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 3
     13   call void @frob(i64** %__a.addr)
     14   br i1 %c, label %if.then, label %if.end
     15 
     16 if.then:                                          ; preds = %entry
     17   br label %return
     18 
     19 if.end:                                           ; preds = %entry
     20   %tmp5 = load i64*, i64** %__a.addr, align 8
     21   br label %return
     22 
     23 return:                                           ; preds = %if.end, %if.then
     24   %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
     25   ret void
     26 }
     27 
     28 ; CHECK-LABEL: @no0(
     29 ; CHECK: br i1 %c
     30 
     31 define void @no0(i1 %c) nounwind {
     32 entry:
     33   %a = alloca [4 x i64*], align 8
     34   %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 4
     35   call void @frob(i64** %__a.addr)
     36   br i1 %c, label %if.then, label %if.end
     37 
     38 if.then:                                          ; preds = %entry
     39   br label %return
     40 
     41 if.end:                                           ; preds = %entry
     42   %tmp5 = load i64*, i64** %__a.addr, align 8
     43   br label %return
     44 
     45 return:                                           ; preds = %if.end, %if.then
     46   %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
     47   ret void
     48 }
     49 
     50 ; CHECK-LABEL: @no1(
     51 ; CHECK: br i1 %c
     52 
     53 define void @no1(i1 %c, i64 %n) nounwind {
     54 entry:
     55   %a = alloca [4 x i64*], align 8
     56   %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 %n
     57   call void @frob(i64** %__a.addr)
     58   br i1 %c, label %if.then, label %if.end
     59 
     60 if.then:                                          ; preds = %entry
     61   br label %return
     62 
     63 if.end:                                           ; preds = %entry
     64   %tmp5 = load i64*, i64** %__a.addr, align 8
     65   br label %return
     66 
     67 return:                                           ; preds = %if.end, %if.then
     68   %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
     69   ret void
     70 }
     71 
     72 ; CHECK-LABEL: @no2(
     73 ; CHECK: br i1 %c
     74 
     75 define void @no2(i1 %c, i64 %n) nounwind {
     76 entry:
     77   %a = alloca [4 x i64*], align 8
     78   %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 1, i64 0
     79   call void @frob(i64** %__a.addr)
     80   br i1 %c, label %if.then, label %if.end
     81 
     82 if.then:                                          ; preds = %entry
     83   br label %return
     84 
     85 if.end:                                           ; preds = %entry
     86   %tmp5 = load i64*, i64** %__a.addr, align 8
     87   br label %return
     88 
     89 return:                                           ; preds = %if.end, %if.then
     90   %storemerge = phi i64* [ undef, %if.then ], [ %tmp5, %if.end ]
     91   ret void
     92 }
     93 
     94 declare void @frob(i64** nocapture %p)
     95