1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -early-cse -earlycse-debug-hash -S < %s | FileCheck %s
3 ; RUN: opt -basic-aa -early-cse-memssa -S < %s | FileCheck %s
5 define i32 @test_01(i32 %a, i32 %b) {
6 ; CHECK-LABEL: @test_01(
8 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
9 ; CHECK-NEXT: br i1 [[COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
11 ; CHECK-NEXT: ret i32 [[A]]
13 ; CHECK-NEXT: ret i32 [[B]]
16 %cond = icmp slt i32 %a, %b
17 br i1 %cond, label %if.true, label %if.false
20 %cond2 = icmp slt i32 %a, %b
21 %x = select i1 %cond2, i32 %a, i32 %b
25 %cond3 = icmp slt i32 %a, %b
26 %y = select i1 %cond3, i32 %a, i32 %b
30 define i32 @test_02(i32 %a, i32 %b, i1 %c) {
31 ; CHECK-LABEL: @test_02(
33 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
34 ; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[COND]], [[C:%.*]]
35 ; CHECK-NEXT: br i1 [[AND_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
37 ; CHECK-NEXT: ret i32 [[A]]
39 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
40 ; CHECK-NEXT: ret i32 [[Y]]
43 %cond = icmp slt i32 %a, %b
44 %and.cond = and i1 %cond, %c
45 br i1 %and.cond, label %if.true, label %if.false
48 %cond2 = icmp slt i32 %a, %b
49 %x = select i1 %cond2, i32 %a, i32 %b
53 %cond3 = icmp slt i32 %a, %b
54 %y = select i1 %cond3, i32 %a, i32 %b
58 define i32 @test_02_select(i32 %a, i32 %b, i1 %c) {
59 ; CHECK-LABEL: @test_02_select(
61 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
62 ; CHECK-NEXT: [[AND_COND:%.*]] = select i1 [[COND]], i1 [[C:%.*]], i1 false
63 ; CHECK-NEXT: br i1 [[AND_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
65 ; CHECK-NEXT: ret i32 [[A]]
67 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
68 ; CHECK-NEXT: ret i32 [[Y]]
71 %cond = icmp slt i32 %a, %b
72 %and.cond = select i1 %cond, i1 %c, i1 false
73 br i1 %and.cond, label %if.true, label %if.false
76 %cond2 = icmp slt i32 %a, %b
77 %x = select i1 %cond2, i32 %a, i32 %b
81 %cond3 = icmp slt i32 %a, %b
82 %y = select i1 %cond3, i32 %a, i32 %b
86 define i32 @test_03(i32 %a, i32 %b, i1 %c) {
87 ; CHECK-LABEL: @test_03(
89 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
90 ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[COND]], [[C:%.*]]
91 ; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
93 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
94 ; CHECK-NEXT: ret i32 [[X]]
96 ; CHECK-NEXT: ret i32 [[B]]
99 %cond = icmp slt i32 %a, %b
100 %or.cond = or i1 %cond, %c
101 br i1 %or.cond, label %if.true, label %if.false
104 %cond2 = icmp slt i32 %a, %b
105 %x = select i1 %cond2, i32 %a, i32 %b
109 %cond3 = icmp slt i32 %a, %b
110 %y = select i1 %cond3, i32 %a, i32 %b
114 define i32 @test_03_select(i32 %a, i32 %b, i1 %c) {
115 ; CHECK-LABEL: @test_03_select(
117 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
118 ; CHECK-NEXT: [[OR_COND:%.*]] = select i1 [[COND]], i1 true, i1 [[C:%.*]]
119 ; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
121 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
122 ; CHECK-NEXT: ret i32 [[X]]
124 ; CHECK-NEXT: ret i32 [[B]]
127 %cond = icmp slt i32 %a, %b
128 %or.cond = select i1 %cond, i1 true, i1 %c
129 br i1 %or.cond, label %if.true, label %if.false
132 %cond2 = icmp slt i32 %a, %b
133 %x = select i1 %cond2, i32 %a, i32 %b
137 %cond3 = icmp slt i32 %a, %b
138 %y = select i1 %cond3, i32 %a, i32 %b
142 define i32 @test_04(i32 %a, i32 %b, i1 %c1, i1 %c2) {
143 ; CHECK-LABEL: @test_04(
145 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
146 ; CHECK-NEXT: [[AND_COND1:%.*]] = and i1 [[COND]], [[C1:%.*]]
147 ; CHECK-NEXT: [[AND_COND2:%.*]] = and i1 [[AND_COND1]], [[C2:%.*]]
148 ; CHECK-NEXT: br i1 [[AND_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
150 ; CHECK-NEXT: ret i32 [[A]]
152 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
153 ; CHECK-NEXT: ret i32 [[Y]]
156 %cond = icmp slt i32 %a, %b
157 %and.cond1 = and i1 %cond, %c1
158 %and.cond2 = and i1 %and.cond1, %c2
159 br i1 %and.cond2, label %if.true, label %if.false
162 %cond2 = icmp slt i32 %a, %b
163 %x = select i1 %cond2, i32 %a, i32 %b
167 %cond3 = icmp slt i32 %a, %b
168 %y = select i1 %cond3, i32 %a, i32 %b
172 define i32 @test_04_select(i32 %a, i32 %b, i1 %c1, i1 %c2) {
173 ; CHECK-LABEL: @test_04_select(
175 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
176 ; CHECK-NEXT: [[AND_COND1:%.*]] = select i1 [[COND]], i1 [[C1:%.*]], i1 false
177 ; CHECK-NEXT: [[AND_COND2:%.*]] = select i1 [[AND_COND1]], i1 [[C2:%.*]], i1 false
178 ; CHECK-NEXT: br i1 [[AND_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
180 ; CHECK-NEXT: ret i32 [[A]]
182 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
183 ; CHECK-NEXT: ret i32 [[Y]]
186 %cond = icmp slt i32 %a, %b
187 %and.cond1 = select i1 %cond, i1 %c1, i1 false
188 %and.cond2 = select i1 %and.cond1, i1 %c2, i1 false
189 br i1 %and.cond2, label %if.true, label %if.false
192 %cond2 = icmp slt i32 %a, %b
193 %x = select i1 %cond2, i32 %a, i32 %b
197 %cond3 = icmp slt i32 %a, %b
198 %y = select i1 %cond3, i32 %a, i32 %b
202 define i32 @test_05(i32 %a, i32 %b, i1 %c1, i1 %c2) {
203 ; CHECK-LABEL: @test_05(
205 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
206 ; CHECK-NEXT: [[OR_COND1:%.*]] = or i1 [[COND]], [[C1:%.*]]
207 ; CHECK-NEXT: [[OR_COND2:%.*]] = or i1 [[OR_COND1]], [[C2:%.*]]
208 ; CHECK-NEXT: br i1 [[OR_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
210 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
211 ; CHECK-NEXT: ret i32 [[X]]
213 ; CHECK-NEXT: ret i32 [[B]]
216 %cond = icmp slt i32 %a, %b
217 %or.cond1 = or i1 %cond, %c1
218 %or.cond2 = or i1 %or.cond1, %c2
219 br i1 %or.cond2, label %if.true, label %if.false
222 %cond2 = icmp slt i32 %a, %b
223 %x = select i1 %cond2, i32 %a, i32 %b
227 %cond3 = icmp slt i32 %a, %b
228 %y = select i1 %cond3, i32 %a, i32 %b
232 define i32 @test_05_select(i32 %a, i32 %b, i1 %c1, i1 %c2) {
233 ; CHECK-LABEL: @test_05_select(
235 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
236 ; CHECK-NEXT: [[OR_COND1:%.*]] = select i1 [[COND]], i1 true, i1 [[C1:%.*]]
237 ; CHECK-NEXT: [[OR_COND2:%.*]] = select i1 [[OR_COND1]], i1 true, i1 [[C2:%.*]]
238 ; CHECK-NEXT: br i1 [[OR_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
240 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
241 ; CHECK-NEXT: ret i32 [[X]]
243 ; CHECK-NEXT: ret i32 [[B]]
246 %cond = icmp slt i32 %a, %b
247 %or.cond1 = select i1 %cond, i1 true, i1 %c1
248 %or.cond2 = select i1 %or.cond1, i1 true, i1 %c2
249 br i1 %or.cond2, label %if.true, label %if.false
252 %cond2 = icmp slt i32 %a, %b
253 %x = select i1 %cond2, i32 %a, i32 %b
257 %cond3 = icmp slt i32 %a, %b
258 %y = select i1 %cond3, i32 %a, i32 %b