diff options
Diffstat (limited to 'test/Transforms/JumpThreading/select.ll')
| -rw-r--r-- | test/Transforms/JumpThreading/select.ll | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/test/Transforms/JumpThreading/select.ll b/test/Transforms/JumpThreading/select.ll index 9676efec9df2..201e604e0c5e 100644 --- a/test/Transforms/JumpThreading/select.ll +++ b/test/Transforms/JumpThreading/select.ll @@ -10,7 +10,7 @@ declare void @quux() ; Mostly theoretical since instruction combining simplifies all selects of ; booleans where at least one operand is true/false/undef. -; CHECK: @test_br +; CHECK-LABEL: @test_br( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 %cond, label %L1, define void @test_br(i1 %cond, i1 %value) nounwind { @@ -34,7 +34,7 @@ L3: ; Jump threading of switch with select as condition. -; CHECK: @test_switch +; CHECK-LABEL: @test_switch( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 %cond, label %L1, define void @test_switch(i1 %cond, i8 %value) nounwind { @@ -69,7 +69,7 @@ L4: ; Jump threading of indirectbr with select as address. -; CHECK: @test_indirectbr +; CHECK-LABEL: @test_indirectbr( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 %cond, label %L1, label %L3 define void @test_indirectbr(i1 %cond, i8* %address) nounwind { @@ -93,7 +93,7 @@ L3: ; A more complicated case: the condition is a select based on a comparison. -; CHECK: @test_switch_cmp +; CHECK-LABEL: @test_switch_cmp( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 %cond, label %L0, label %[[THREADED:[A-Za-z.0-9]+]] ; CHECK: [[THREADED]]: @@ -157,3 +157,66 @@ L3: L4: ret void } + +define void @unfold1(double %x, double %y) nounwind { +entry: + %sub = fsub double %x, %y + %cmp = fcmp ogt double %sub, 1.000000e+01 + br i1 %cmp, label %cond.end4, label %cond.false + +cond.false: ; preds = %entry + %add = fadd double %x, %y + %cmp1 = fcmp ogt double %add, 1.000000e+01 + %add. = select i1 %cmp1, double %add, double 0.000000e+00 + br label %cond.end4 + +cond.end4: ; preds = %entry, %cond.false + %cond5 = phi double [ %add., %cond.false ], [ %sub, %entry ] + %cmp6 = fcmp oeq double %cond5, 0.000000e+00 + br i1 %cmp6, label %if.then, label %if.end + +if.then: ; preds = %cond.end4 + call void @foo() + br label %if.end + +if.end: ; preds = %if.then, %cond.end4 + ret void + +; CHECK-LABEL: @unfold1 +; CHECK: br i1 %cmp, label %cond.end4, label %cond.false +; CHECK: br i1 %cmp1, label %cond.end4, label %if.then +; CHECK: br i1 %cmp6, label %if.then, label %if.end +; CHECK: br label %if.end +} + + +define void @unfold2(i32 %x, i32 %y) nounwind { +entry: + %sub = sub nsw i32 %x, %y + %cmp = icmp sgt i32 %sub, 10 + br i1 %cmp, label %cond.end4, label %cond.false + +cond.false: ; preds = %entry + %add = add nsw i32 %x, %y + %cmp1 = icmp sgt i32 %add, 10 + %add. = select i1 %cmp1, i32 0, i32 %add + br label %cond.end4 + +cond.end4: ; preds = %entry, %cond.false + %cond5 = phi i32 [ %add., %cond.false ], [ %sub, %entry ] + %cmp6 = icmp eq i32 %cond5, 0 + br i1 %cmp6, label %if.then, label %if.end + +if.then: ; preds = %cond.end4 + call void @foo() + br label %if.end + +if.end: ; preds = %if.then, %cond.end4 + ret void + +; CHECK-LABEL: @unfold2 +; CHECK: br i1 %cmp, label %if.end, label %cond.false +; CHECK: br i1 %cmp1, label %if.then, label %cond.end4 +; CHECK: br i1 %cmp6, label %if.then, label %if.end +; CHECK: br label %if.end +} |
