1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
6 define i1 @test1(i32 %a, i32 %b) {
8 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b
9 ; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
10 ; CHECK-NEXT: ret i1 [[TMP2]]
12 %1 = icmp slt i32 %a, 0
13 %2 = icmp slt i32 %b, 0
14 %or.cond = or i1 %1, %2
18 define 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]]
24 %1 = icmp sgt i32 %a, -1
25 %2 = icmp sgt i32 %b, -1
26 %or.cond = or i1 %1, %2
30 define 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]]
36 %1 = icmp slt i32 %a, 0
37 %2 = icmp slt i32 %b, 0
38 %or.cond = and i1 %1, %2
42 define 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]]
48 %1 = icmp sgt i32 %a, -1
49 %2 = icmp sgt i32 %b, -1
50 %or.cond = and i1 %1, %2
54 define 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
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
68 tail call void @foo() nounwind
75 define 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
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
89 tail call void @foo() nounwind
96 define 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
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
110 tail call void @foo() nounwind
117 define 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
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
131 tail call void @foo()
138 define 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]]
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
151 define i1 @test10(i32 %a) {
152 ; CHECK-LABEL: @test10(
153 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 %a, 2
154 ; CHECK-NEXT: ret i1 [[TMP1]]
157 %2 = icmp eq i32 %1, 0
158 %3 = icmp ult i32 %a, 4
159 %or.cond = and i1 %2, %3
163 define i1 @test11(i32 %a) {
164 ; CHECK-LABEL: @test11(
165 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %a, 1
166 ; CHECK-NEXT: ret i1 [[TMP1]]
169 %2 = icmp ne i32 %1, 0
170 %3 = icmp ugt i32 %a, 3
171 %or.cond = or i1 %2, %3