1*cee313d2SEric Christopher; RUN: opt -jump-threading -S < %s | FileCheck %s 2*cee313d2SEric Christopher 3*cee313d2SEric Christopherdeclare void @side_effect(i32) 4*cee313d2SEric Christopher 5*cee313d2SEric Christopherdefine void @test0(i32 %i, i32 %len) { 6*cee313d2SEric Christopher; CHECK-LABEL: @test0( 7*cee313d2SEric Christopher entry: 8*cee313d2SEric Christopher call void @side_effect(i32 0) 9*cee313d2SEric Christopher %i.inc = add nuw i32 %i, 1 10*cee313d2SEric Christopher %c0 = icmp ult i32 %i.inc, %len 11*cee313d2SEric Christopher br i1 %c0, label %left, label %right 12*cee313d2SEric Christopher 13*cee313d2SEric Christopher left: 14*cee313d2SEric Christopher; CHECK: entry: 15*cee313d2SEric Christopher; CHECK: br i1 %c0, label %left0, label %right 16*cee313d2SEric Christopher 17*cee313d2SEric Christopher; CHECK: left0: 18*cee313d2SEric Christopher; CHECK: call void @side_effect 19*cee313d2SEric Christopher; CHECK-NOT: br i1 %c1 20*cee313d2SEric Christopher; CHECK: call void @side_effect 21*cee313d2SEric Christopher call void @side_effect(i32 0) 22*cee313d2SEric Christopher %c1 = icmp ult i32 %i, %len 23*cee313d2SEric Christopher br i1 %c1, label %left0, label %right 24*cee313d2SEric Christopher 25*cee313d2SEric Christopher left0: 26*cee313d2SEric Christopher call void @side_effect(i32 0) 27*cee313d2SEric Christopher ret void 28*cee313d2SEric Christopher 29*cee313d2SEric Christopher right: 30*cee313d2SEric Christopher %t = phi i32 [ 1, %left ], [ 2, %entry ] 31*cee313d2SEric Christopher call void @side_effect(i32 %t) 32*cee313d2SEric Christopher ret void 33*cee313d2SEric Christopher} 34*cee313d2SEric Christopher 35*cee313d2SEric Christopherdefine void @test1(i32 %i, i32 %len) { 36*cee313d2SEric Christopher; CHECK-LABEL: @test1( 37*cee313d2SEric Christopher entry: 38*cee313d2SEric Christopher call void @side_effect(i32 0) 39*cee313d2SEric Christopher %i.inc = add nsw i32 %i, 1 40*cee313d2SEric Christopher %c0 = icmp slt i32 %i.inc, %len 41*cee313d2SEric Christopher br i1 %c0, label %left, label %right 42*cee313d2SEric Christopher 43*cee313d2SEric Christopher left: 44*cee313d2SEric Christopher; CHECK: entry: 45*cee313d2SEric Christopher; CHECK: br i1 %c0, label %left0, label %right 46*cee313d2SEric Christopher 47*cee313d2SEric Christopher; CHECK: left0: 48*cee313d2SEric Christopher; CHECK: call void @side_effect 49*cee313d2SEric Christopher; CHECK-NOT: br i1 %c1 50*cee313d2SEric Christopher; CHECK: call void @side_effect 51*cee313d2SEric Christopher call void @side_effect(i32 0) 52*cee313d2SEric Christopher %c1 = icmp slt i32 %i, %len 53*cee313d2SEric Christopher br i1 %c1, label %left0, label %right 54*cee313d2SEric Christopher 55*cee313d2SEric Christopher left0: 56*cee313d2SEric Christopher call void @side_effect(i32 0) 57*cee313d2SEric Christopher ret void 58*cee313d2SEric Christopher 59*cee313d2SEric Christopher right: 60*cee313d2SEric Christopher %t = phi i32 [ 1, %left ], [ 2, %entry ] 61*cee313d2SEric Christopher call void @side_effect(i32 %t) 62*cee313d2SEric Christopher ret void 63*cee313d2SEric Christopher} 64*cee313d2SEric Christopher 65*cee313d2SEric Christopherdefine void @test2(i32 %i, i32 %len, i1* %c.ptr) { 66*cee313d2SEric Christopher; CHECK-LABEL: @test2( 67*cee313d2SEric Christopher 68*cee313d2SEric Christopher; CHECK: entry: 69*cee313d2SEric Christopher; CHECK: br i1 %c0, label %cont, label %right 70*cee313d2SEric Christopher; CHECK: cont: 71*cee313d2SEric Christopher; CHECK: br i1 %c, label %left0, label %right 72*cee313d2SEric Christopher; CHECK: left0: 73*cee313d2SEric Christopher; CHECK: call void @side_effect(i32 0) 74*cee313d2SEric Christopher; CHECK: call void @side_effect(i32 0) 75*cee313d2SEric Christopher entry: 76*cee313d2SEric Christopher call void @side_effect(i32 0) 77*cee313d2SEric Christopher %i.inc = add nsw i32 %i, 1 78*cee313d2SEric Christopher %c0 = icmp slt i32 %i.inc, %len 79*cee313d2SEric Christopher br i1 %c0, label %cont, label %right 80*cee313d2SEric Christopher 81*cee313d2SEric Christopher cont: 82*cee313d2SEric Christopher %c = load i1, i1* %c.ptr 83*cee313d2SEric Christopher br i1 %c, label %left, label %right 84*cee313d2SEric Christopher 85*cee313d2SEric Christopher left: 86*cee313d2SEric Christopher call void @side_effect(i32 0) 87*cee313d2SEric Christopher %c1 = icmp slt i32 %i, %len 88*cee313d2SEric Christopher br i1 %c1, label %left0, label %right 89*cee313d2SEric Christopher 90*cee313d2SEric Christopher left0: 91*cee313d2SEric Christopher call void @side_effect(i32 0) 92*cee313d2SEric Christopher ret void 93*cee313d2SEric Christopher 94*cee313d2SEric Christopher right: 95*cee313d2SEric Christopher %t = phi i32 [ 1, %left ], [ 2, %entry ], [ 3, %cont ] 96*cee313d2SEric Christopher call void @side_effect(i32 %t) 97*cee313d2SEric Christopher ret void 98*cee313d2SEric Christopher} 99*cee313d2SEric Christopher 100*cee313d2SEric Christopher; A s<= B implies A s> B is false. 101*cee313d2SEric Christopher; CHECK-LABEL: @test3( 102*cee313d2SEric Christopher; CHECK: entry: 103*cee313d2SEric Christopher; CHECK: br i1 %cmp, label %if.end, label %if.end3 104*cee313d2SEric Christopher; CHECK-NOT: br i1 %cmp1, label %if.then2, label %if.end 105*cee313d2SEric Christopher; CHECK-NOT: call void @side_effect(i32 0) 106*cee313d2SEric Christopher; CHECK: br label %if.end3 107*cee313d2SEric Christopher; CHECK: ret void 108*cee313d2SEric Christopher 109*cee313d2SEric Christopherdefine void @test3(i32 %a, i32 %b) { 110*cee313d2SEric Christopherentry: 111*cee313d2SEric Christopher %cmp = icmp sle i32 %a, %b 112*cee313d2SEric Christopher br i1 %cmp, label %if.then, label %if.end3 113*cee313d2SEric Christopher 114*cee313d2SEric Christopherif.then: 115*cee313d2SEric Christopher %cmp1 = icmp sgt i32 %a, %b 116*cee313d2SEric Christopher br i1 %cmp1, label %if.then2, label %if.end 117*cee313d2SEric Christopher 118*cee313d2SEric Christopherif.then2: 119*cee313d2SEric Christopher call void @side_effect(i32 0) 120*cee313d2SEric Christopher br label %if.end 121*cee313d2SEric Christopher 122*cee313d2SEric Christopherif.end: 123*cee313d2SEric Christopher br label %if.end3 124*cee313d2SEric Christopher 125*cee313d2SEric Christopherif.end3: 126*cee313d2SEric Christopher ret void 127*cee313d2SEric Christopher} 128*cee313d2SEric Christopher 129*cee313d2SEric Christopherdeclare void @is(i1) 130*cee313d2SEric Christopher 131*cee313d2SEric Christopher; If A >=s B is false then A <=s B is implied true. 132*cee313d2SEric Christopher; CHECK-LABEL: @test_sge_sle 133*cee313d2SEric Christopher; CHECK: call void @is(i1 true) 134*cee313d2SEric Christopher; CHECK-NOT: call void @is(i1 false) 135*cee313d2SEric Christopherdefine void @test_sge_sle(i32 %a, i32 %b) { 136*cee313d2SEric Christopher %cmp1 = icmp sge i32 %a, %b 137*cee313d2SEric Christopher br i1 %cmp1, label %untaken, label %taken 138*cee313d2SEric Christopher 139*cee313d2SEric Christophertaken: 140*cee313d2SEric Christopher %cmp2 = icmp sle i32 %a, %b 141*cee313d2SEric Christopher br i1 %cmp2, label %istrue, label %isfalse 142*cee313d2SEric Christopher 143*cee313d2SEric Christopheristrue: 144*cee313d2SEric Christopher call void @is(i1 true) 145*cee313d2SEric Christopher ret void 146*cee313d2SEric Christopher 147*cee313d2SEric Christopherisfalse: 148*cee313d2SEric Christopher call void @is(i1 false) 149*cee313d2SEric Christopher ret void 150*cee313d2SEric Christopher 151*cee313d2SEric Christopheruntaken: 152*cee313d2SEric Christopher ret void 153*cee313d2SEric Christopher} 154*cee313d2SEric Christopher 155*cee313d2SEric Christopher; If A <=s B is false then A <=s B is implied false. 156*cee313d2SEric Christopher; CHECK-LABEL: @test_sle_sle 157*cee313d2SEric Christopher; CHECK-NOT: call void @is(i1 true) 158*cee313d2SEric Christopher; CHECK: call void @is(i1 false) 159*cee313d2SEric Christopherdefine void @test_sle_sle(i32 %a, i32 %b) { 160*cee313d2SEric Christopher %cmp1 = icmp sle i32 %a, %b 161*cee313d2SEric Christopher br i1 %cmp1, label %untaken, label %taken 162*cee313d2SEric Christopher 163*cee313d2SEric Christophertaken: 164*cee313d2SEric Christopher %cmp2 = icmp sle i32 %a, %b 165*cee313d2SEric Christopher br i1 %cmp2, label %istrue, label %isfalse 166*cee313d2SEric Christopher 167*cee313d2SEric Christopheristrue: 168*cee313d2SEric Christopher call void @is(i1 true) 169*cee313d2SEric Christopher ret void 170*cee313d2SEric Christopher 171*cee313d2SEric Christopherisfalse: 172*cee313d2SEric Christopher call void @is(i1 false) 173*cee313d2SEric Christopher ret void 174*cee313d2SEric Christopher 175*cee313d2SEric Christopheruntaken: 176*cee313d2SEric Christopher ret void 177*cee313d2SEric Christopher} 178