1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -instcombine < %s | FileCheck %s 3 4declare void @foo() 5 6define i1 @test1(i32 %a, i32 %b) { 7; CHECK-LABEL: @test1( 8; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b 9; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0 10; CHECK-NEXT: ret i1 [[TMP2]] 11; 12 %1 = icmp slt i32 %a, 0 13 %2 = icmp slt i32 %b, 0 14 %or.cond = or i1 %1, %2 15 ret i1 %or.cond 16} 17 18define i1 @test2(i32 %a, i32 %b) { 19; CHECK-LABEL: @test2( 20; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b 21; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1 22; CHECK-NEXT: ret i1 [[TMP2]] 23; 24 %1 = icmp sgt i32 %a, -1 25 %2 = icmp sgt i32 %b, -1 26 %or.cond = or i1 %1, %2 27 ret i1 %or.cond 28} 29 30define i1 @test3(i32 %a, i32 %b) { 31; CHECK-LABEL: @test3( 32; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b 33; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0 34; CHECK-NEXT: ret i1 [[TMP2]] 35; 36 %1 = icmp slt i32 %a, 0 37 %2 = icmp slt i32 %b, 0 38 %or.cond = and i1 %1, %2 39 ret i1 %or.cond 40} 41 42define i1 @test4(i32 %a, i32 %b) { 43; CHECK-LABEL: @test4( 44; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b 45; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1 46; CHECK-NEXT: ret i1 [[TMP2]] 47; 48 %1 = icmp sgt i32 %a, -1 49 %2 = icmp sgt i32 %b, -1 50 %or.cond = and i1 %1, %2 51 ret i1 %or.cond 52} 53 54define void @test5(i32 %a) { 55; CHECK-LABEL: @test5( 56; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920 57; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 58; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end 59; 60 %and = and i32 %a, 134217728 61 %1 = icmp eq i32 %and, 0 62 %2 = icmp sgt i32 %a, -1 63 %or.cond = and i1 %1, %2 64 br i1 %or.cond, label %if.then, label %if.end 65 66 67if.then: 68 tail call void @foo() nounwind 69 ret void 70 71if.end: 72 ret void 73} 74 75define void @test6(i32 %a) { 76; CHECK-LABEL: @test6( 77; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920 78; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 79; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end 80; 81 %1 = icmp sgt i32 %a, -1 82 %and = and i32 %a, 134217728 83 %2 = icmp eq i32 %and, 0 84 %or.cond = and i1 %1, %2 85 br i1 %or.cond, label %if.then, label %if.end 86 87 88if.then: 89 tail call void @foo() nounwind 90 ret void 91 92if.end: 93 ret void 94} 95 96define void @test7(i32 %a) { 97; CHECK-LABEL: @test7( 98; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920 99; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 100; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then 101; 102 %and = and i32 %a, 134217728 103 %1 = icmp ne i32 %and, 0 104 %2 = icmp slt i32 %a, 0 105 %or.cond = or i1 %1, %2 106 br i1 %or.cond, label %if.then, label %if.end 107 108 109if.then: 110 tail call void @foo() nounwind 111 ret void 112 113if.end: 114 ret void 115} 116 117define void @test8(i32 %a) { 118; CHECK-LABEL: @test8( 119; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920 120; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 121; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then 122; 123 %1 = icmp slt i32 %a, 0 124 %and = and i32 %a, 134217728 125 %2 = icmp ne i32 %and, 0 126 %or.cond = or i1 %1, %2 127 br i1 %or.cond, label %if.then, label %if.end 128 129 130if.then: 131 tail call void @foo() 132 ret void 133 134if.end: 135 ret void 136} 137 138define i1 @test9(i32 %a) { 139; CHECK-LABEL: @test9( 140; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -1073741824 141; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 1073741824 142; CHECK-NEXT: ret i1 [[TMP2]] 143; 144 %1 = and i32 %a, 1073741824 145 %2 = icmp ne i32 %1, 0 146 %3 = icmp sgt i32 %a, -1 147 %or.cond = and i1 %2, %3 148 ret i1 %or.cond 149} 150 151define i1 @test10(i32 %a) { 152; CHECK-LABEL: @test10( 153; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 %a, 2 154; CHECK-NEXT: ret i1 [[TMP1]] 155; 156 %1 = and i32 %a, 2 157 %2 = icmp eq i32 %1, 0 158 %3 = icmp ult i32 %a, 4 159 %or.cond = and i1 %2, %3 160 ret i1 %or.cond 161} 162 163define i1 @test11(i32 %a) { 164; CHECK-LABEL: @test11( 165; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %a, 1 166; CHECK-NEXT: ret i1 [[TMP1]] 167; 168 %1 = and i32 %a, 2 169 %2 = icmp ne i32 %1, 0 170 %3 = icmp ugt i32 %a, 3 171 %or.cond = or i1 %2, %3 172 ret i1 %or.cond 173} 174