1; RUN: opt %s -S -simplifycfg | FileCheck %s 2 3; cmp1 implies cmp2 is false 4; CHECK-LABEL: @test1 5; CHECK-NOT: call void @is(i1 true) 6; CHECK: call void @is(i1 false) 7define void @test1(i32 %a) { 8 %cmp1 = icmp eq i32 %a, 0 9 br i1 %cmp1, label %taken, label %untaken 10 11taken: 12 %cmp2 = icmp eq i32 %a, 1 13 br i1 %cmp2, label %istrue, label %isfalse 14 15istrue: 16 call void @is(i1 true) 17 ret void 18 19isfalse: 20 call void @is(i1 false) 21 ret void 22 23untaken: 24 ret void 25} 26 27; cmp1 implies cmp2 is false 28; CHECK-LABEL: @test2 29; CHECK-NOT: call void @is(i1 true) 30; CHECK: call void @is(i1 false) 31define void @test2(i32 %a) { 32 %cmp1 = icmp ugt i32 %a, 5 33 br i1 %cmp1, label %untaken, label %taken 34 35taken: 36 %cmp2 = icmp ugt i32 %a, 6 37 br i1 %cmp2, label %istrue, label %isfalse 38 39istrue: 40 call void @is(i1 true) 41 ret void 42 43isfalse: 44 call void @is(i1 false) 45 ret void 46 47untaken: 48 ret void 49} 50 51; cmp1 implies cmp2 is false 52; CHECK-LABEL: @test3 53; CHECK-NOT: call void @is(i1 true) 54; CHECK: call void @is(i1 false) 55define void @test3(i32 %a) { 56 %cmp1 = icmp ugt i32 %a, 1 57 br i1 %cmp1, label %taken, label %untaken 58 59taken: 60 %cmp2 = icmp eq i32 %a, 0 61 br i1 %cmp2, label %istrue, label %isfalse 62 63istrue: 64 call void @is(i1 true) 65 ret void 66 67isfalse: 68 call void @is(i1 false) 69 ret void 70 71untaken: 72 ret void 73} 74 75; cmp1 implies cmp2 is true 76; CHECK-LABEL: @test4 77; CHECK: call void @is(i1 true) 78; CHECK-NOT: call void @is(i1 false) 79define void @test4(i32 %a) { 80 %cmp1 = icmp sgt i32 %a, 1 81 br i1 %cmp1, label %taken, label %untaken 82 83taken: 84 %cmp2 = icmp ugt i32 %a, 0 85 br i1 %cmp2, label %istrue, label %isfalse 86 87istrue: 88 call void @is(i1 true) 89 ret void 90 91isfalse: 92 call void @is(i1 false) 93 ret void 94 95untaken: 96 ret void 97} 98 99; cmp1 implies cmp2 is true 100; CHECK-LABEL: @test5 101; CHECK: call void @is(i1 true) 102; CHECK-NOT: call void @is(i1 false) 103define void @test5(i32 %a) { 104 %cmp1 = icmp sgt i32 %a, 5 105 br i1 %cmp1, label %taken, label %untaken 106 107taken: 108 %cmp2 = icmp sgt i32 %a, -1 109 br i1 %cmp2, label %istrue, label %isfalse 110 111istrue: 112 call void @is(i1 true) 113 ret void 114 115isfalse: 116 call void @is(i1 false) 117 ret void 118 119untaken: 120 ret void 121} 122 123declare void @is(i1) 124