1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
6 define i1 @test_and_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
7 ; CHECK-LABEL: @test_and_ule(
9 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
11 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[C_1]], [[C_2]]
12 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
15 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
16 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
17 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_3]]
18 ; CHECK-NEXT: ret i1 [[R_3]]
20 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[Z]]
21 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
22 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[C_4]], [[C_5]]
23 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Y]]
24 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_6]]
25 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[Y]], [[Z]]
26 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_7]]
27 ; CHECK-NEXT: ret i1 [[R_6]]
30 %c.1 = icmp ule i4 %x, %y
31 %c.2 = icmp ule i4 %y, %z
32 %and = and i1 %c.1, %c.2
33 br i1 %and, label %bb1, label %exit
36 %t.1 = icmp ule i4 %x, %z
37 %t.2 = icmp ule i4 %x, %y
38 %r.1 = xor i1 %t.1, %t.2
40 %t.3 = icmp ule i4 %y, %z
41 %r.2 = xor i1 %r.1, %t.3
44 %c.3 = icmp ule i4 %x, %a
45 %r.3 = xor i1 %r.2, %c.3
50 %c.4 = icmp ule i4 %x, %z
51 %c.5 = icmp ule i4 %x, %a
52 %r.4 = xor i1 %c.4, %c.5
54 %c.6 = icmp ule i4 %x, %y
55 %r.5 = xor i1 %r.4, %c.6
57 %c.7 = icmp ule i4 %y, %z
58 %r.6 = xor i1 %r.5, %c.7
63 ; The result of test_and_ule and test_and_select_ule should be same
64 define i1 @test_and_select_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
65 ; CHECK-LABEL: @test_and_select_ule(
67 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
68 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
69 ; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_1]], i1 [[C_2]], i1 false
70 ; CHECK-NEXT: br i1 [[AND]], label [[BB1:%.*]], label [[EXIT:%.*]]
72 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
73 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
74 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 [[X]], [[A:%.*]]
75 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_3]]
76 ; CHECK-NEXT: ret i1 [[R_3]]
78 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 [[X]], [[Z]]
79 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
80 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[C_4]], [[C_5]]
81 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Y]]
82 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_6]]
83 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[Y]], [[Z]]
84 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_7]]
85 ; CHECK-NEXT: ret i1 [[R_6]]
88 %c.1 = icmp ule i4 %x, %y
89 %c.2 = icmp ule i4 %y, %z
90 %and = select i1 %c.1, i1 %c.2, i1 false
91 br i1 %and, label %bb1, label %exit
94 %t.1 = icmp ule i4 %x, %z
95 %t.2 = icmp ule i4 %x, %y
96 %r.1 = xor i1 %t.1, %t.2
98 %t.3 = icmp ule i4 %y, %z
99 %r.2 = xor i1 %r.1, %t.3
101 %c.3 = icmp ule i4 %x, %a
102 %r.3 = xor i1 %r.2, %c.3
106 %c.4 = icmp ule i4 %x, %z
107 %c.5 = icmp ule i4 %x, %a
108 %r.4 = xor i1 %c.4, %c.5
110 %c.6 = icmp ule i4 %x, %y
111 %r.5 = xor i1 %r.4, %c.6
113 %c.7 = icmp ule i4 %y, %z
114 %r.6 = xor i1 %r.5, %c.7
118 define i4 @and_compare_undef(i4 %N, i4 %step) {
119 ; CHECK-LABEL: @and_compare_undef(
120 ; CHECK-NEXT: step.check:
121 ; CHECK-NEXT: [[B1:%.*]] = add i4 undef, -1
122 ; CHECK-NEXT: [[STEP_ULT_N:%.*]] = icmp ult i4 [[B1]], [[N:%.*]]
123 ; CHECK-NEXT: [[AND_STEP:%.*]] = and i1 true, [[STEP_ULT_N]]
124 ; CHECK-NEXT: br i1 [[AND_STEP]], label [[PTR_CHECK:%.*]], label [[EXIT:%.*]]
126 ; CHECK-NEXT: br label [[EXIT]]
128 ; CHECK-NEXT: ret i4 3
131 %step.pos = icmp uge i4 %step, 0
132 %B1 = add i4 undef, -1
133 %step.ult.N = icmp ult i4 %B1, %N
134 %and.step = and i1 %step.pos, %step.ult.N
135 br i1 %and.step, label %ptr.check, label %exit
144 define i1 @test_and_condition_trivially_false(i1 %c, ptr %ptr.1, i8 %idx, ptr %ptr.2) {
145 ; CHECK-LABEL: @test_and_condition_trivially_false(
147 ; CHECK-NEXT: br i1 [[C:%.*]], label [[THEN:%.*]], label [[EXIT_3:%.*]]
149 ; CHECK-NEXT: [[IDX_EXT:%.*]] = zext i8 [[IDX:%.*]] to i16
150 ; CHECK-NEXT: [[GEP_IDX_EXT:%.*]] = getelementptr inbounds i8, ptr [[PTR_1:%.*]], i16 [[IDX_EXT]]
151 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ult ptr [[PTR_2:%.*]], [[GEP_IDX_EXT]]
152 ; CHECK-NEXT: [[AND:%.*]] = and i1 false, [[CMP_2]]
153 ; CHECK-NEXT: br i1 [[AND]], label [[EXIT_1:%.*]], label [[EXIT_2:%.*]]
155 ; CHECK-NEXT: ret i1 true
157 ; CHECK-NEXT: ret i1 false
159 ; CHECK-NEXT: [[CMP_3:%.*]] = icmp ne i8 [[IDX]], 0
160 ; CHECK-NEXT: ret i1 [[CMP_3]]
163 br i1 %c, label %then, label %exit.3
166 %cmp.1 = icmp ugt ptr %ptr.2, %ptr.2
167 %idx.ext = zext i8 %idx to i16
168 %gep.idx.ext = getelementptr inbounds i8, ptr %ptr.1, i16 %idx.ext
169 %cmp.2 = icmp ult ptr %ptr.2, %gep.idx.ext
170 %and = and i1 %cmp.1, %cmp.2
171 br i1 %and, label %exit.1, label %exit.2
180 %cmp.3 = icmp ne i8 %idx, 0
184 define i1 @test_and_chain_ule_1(i4 %x, i4 %y, i4 %z, i4 %a) {
185 ; CHECK-LABEL: @test_and_chain_ule_1(
187 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
188 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
189 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
190 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
191 ; CHECK-NEXT: [[AND_1:%.*]] = and i1 [[C_1]], [[C_2]]
192 ; CHECK-NEXT: [[AND_2:%.*]] = and i1 [[AND_1]], [[C_3]]
193 ; CHECK-NEXT: [[AND_3:%.*]] = and i1 [[C_4]], [[AND_2]]
194 ; CHECK-NEXT: br i1 [[AND_3]], label [[BB1:%.*]], label [[EXIT:%.*]]
196 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
197 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
198 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], true
199 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], true
200 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
201 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
202 ; CHECK-NEXT: ret i1 [[R_5]]
204 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
205 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
206 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
207 ; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
208 ; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
209 ; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
210 ; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
211 ; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
212 ; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
213 ; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
214 ; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
215 ; CHECK-NEXT: ret i1 [[R_10]]
218 %c.1 = icmp ule i4 %x, %y
219 %c.2 = icmp ule i4 %y, %z
220 %c.3 = icmp ule i4 3, %x
221 %c.4 = icmp ule i4 3, %a
222 %and.1 = and i1 %c.1, %c.2
223 %and.2 = and i1 %and.1, %c.3
224 %and.3 = and i1 %c.4, %and.2
225 br i1 %and.3, label %bb1, label %exit
228 %t.1 = icmp ule i4 %x, %z
229 %t.2 = icmp ule i4 %x, %y
230 %r.1 = xor i1 %t.1, %t.2
232 %t.3 = icmp ule i4 %y, %z
233 %r.2 = xor i1 %r.1, %t.3
235 %t.4 = icmp ule i4 3, %x
236 %r.3 = xor i1 %r.2, %t.4
238 %t.5 = icmp ule i4 3, %a
239 %r.4 = xor i1 %r.3, %t.5
241 %c.5 = icmp ule i4 %x, %a
242 %r.5 = xor i1 %r.4, %c.5
247 %c.6 = icmp ule i4 %x, %z
248 %c.7 = icmp ule i4 %x, %a
249 %r.6 = xor i1 %c.6, %c.7
251 %c.8 = icmp ule i4 %x, %y
252 %r.7 = xor i1 %r.6, %c.8
254 %c.9 = icmp ule i4 %y, %z
255 %r.8 = xor i1 %r.7, %c.9
257 %c.10 = icmp ule i4 3, %x
258 %r.9 = xor i1 %r.8, %c.10
260 %c.11 = icmp ule i4 3, %a
261 %r.10 = xor i1 %r.9, %c.11
266 ; Same as @test_and_chain_ule_1 but with `and`s reordered.
267 define i1 @test_and_chain_ule_2(i4 %x, i4 %y, i4 %z, i4 %a) {
268 ; CHECK-LABEL: @test_and_chain_ule_2(
270 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
271 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
272 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
273 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
274 ; CHECK-NEXT: [[AND_1:%.*]] = and i1 [[C_1]], [[C_2]]
275 ; CHECK-NEXT: [[AND_2:%.*]] = and i1 [[C_3]], [[C_4]]
276 ; CHECK-NEXT: [[AND_3:%.*]] = and i1 [[AND_1]], [[AND_2]]
277 ; CHECK-NEXT: br i1 [[AND_3]], label [[BB1:%.*]], label [[EXIT:%.*]]
279 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
280 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
281 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], true
282 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], true
283 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
284 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
285 ; CHECK-NEXT: ret i1 [[R_5]]
287 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
288 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
289 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
290 ; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
291 ; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
292 ; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
293 ; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
294 ; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
295 ; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
296 ; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
297 ; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
298 ; CHECK-NEXT: ret i1 [[R_10]]
301 %c.1 = icmp ule i4 %x, %y
302 %c.2 = icmp ule i4 %y, %z
303 %c.3 = icmp ule i4 3, %x
304 %c.4 = icmp ule i4 3, %a
305 %and.1 = and i1 %c.1, %c.2
306 %and.2 = and i1 %c.3, %c.4
307 %and.3 = and i1 %and.1, %and.2
308 br i1 %and.3, label %bb1, label %exit
311 %t.1 = icmp ule i4 %x, %z
312 %t.2 = icmp ule i4 %x, %y
313 %r.1 = xor i1 %t.1, %t.2
315 %t.3 = icmp ule i4 %y, %z
316 %r.2 = xor i1 %r.1, %t.3
318 %t.4 = icmp ule i4 3, %x
319 %r.3 = xor i1 %r.2, %t.4
321 %t.5 = icmp ule i4 3, %a
322 %r.4 = xor i1 %r.3, %t.5
324 %c.5 = icmp ule i4 %x, %a
325 %r.5 = xor i1 %r.4, %c.5
330 %c.6 = icmp ule i4 %x, %z
331 %c.7 = icmp ule i4 %x, %a
332 %r.6 = xor i1 %c.6, %c.7
334 %c.8 = icmp ule i4 %x, %y
335 %r.7 = xor i1 %r.6, %c.8
337 %c.9 = icmp ule i4 %y, %z
338 %r.8 = xor i1 %r.7, %c.9
340 %c.10 = icmp ule i4 3, %x
341 %r.9 = xor i1 %r.8, %c.10
343 %c.11 = icmp ule i4 3, %a
344 %r.10 = xor i1 %r.9, %c.11
350 declare i1 @cond() readnone
352 define i1 @test_and_chain_with_other_insts_ule(i4 %x, i4 %y, i4 %z, i4 %a, i1 %arg.c) {
353 ; CHECK-LABEL: @test_and_chain_with_other_insts_ule(
355 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
356 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
357 ; CHECK-NEXT: [[C_3:%.*]] = call i1 @cond()
358 ; CHECK-NEXT: [[AND_1:%.*]] = and i1 [[C_1]], [[C_2]]
359 ; CHECK-NEXT: [[AND_2:%.*]] = and i1 [[C_3]], [[ARG_C:%.*]]
360 ; CHECK-NEXT: [[AND_3:%.*]] = and i1 [[AND_1]], [[AND_2]]
361 ; CHECK-NEXT: br i1 [[AND_3]], label [[BB1:%.*]], label [[EXIT:%.*]]
363 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, true
364 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], true
365 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[X]]
366 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
367 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 3, [[A:%.*]]
368 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], [[C_5]]
369 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[A]]
370 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_6]]
371 ; CHECK-NEXT: ret i1 [[R_5]]
373 ; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Z]]
374 ; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[X]], [[A]]
375 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_8]], [[C_9]]
376 ; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 [[X]], [[Y]]
377 ; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_10]]
378 ; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 [[Y]], [[Z]]
379 ; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_11]]
380 ; CHECK-NEXT: [[C_12:%.*]] = icmp ule i4 3, [[X]]
381 ; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_12]]
382 ; CHECK-NEXT: [[C_13:%.*]] = icmp ule i4 3, [[A]]
383 ; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_13]]
384 ; CHECK-NEXT: ret i1 [[R_10]]
387 %c.1 = icmp ule i4 %x, %y
388 %c.2 = icmp ule i4 %y, %z
389 %c.3 = call i1 @cond()
390 %and.1 = and i1 %c.1, %c.2
391 %and.2 = and i1 %c.3, %arg.c
392 %and.3 = and i1 %and.1, %and.2
393 br i1 %and.3, label %bb1, label %exit
396 %t.1 = icmp ule i4 %x, %z
397 %t.2 = icmp ule i4 %x, %y
398 %r.1 = xor i1 %t.1, %t.2
400 %t.3 = icmp ule i4 %y, %z
401 %r.2 = xor i1 %r.1, %t.3
403 %c.4 = icmp ule i4 3, %x
404 %r.3 = xor i1 %r.2, %c.4
406 %c.5 = icmp ule i4 3, %a
407 %r.4 = xor i1 %r.3, %c.5
409 %c.6 = icmp ule i4 %x, %a
410 %r.5 = xor i1 %r.4, %c.6
415 %c.8 = icmp ule i4 %x, %z
416 %c.9 = icmp ule i4 %x, %a
417 %r.6 = xor i1 %c.8, %c.9
419 %c.10 = icmp ule i4 %x, %y
420 %r.7 = xor i1 %r.6, %c.10
422 %c.11 = icmp ule i4 %y, %z
423 %r.8 = xor i1 %r.7, %c.11
425 %c.12 = icmp ule i4 3, %x
426 %r.9 = xor i1 %r.8, %c.12
428 %c.13 = icmp ule i4 3, %a
429 %r.10 = xor i1 %r.9, %c.13
434 define i1 @test_and_chain_select_ule(i4 %x, i4 %y, i4 %z, i4 %a) {
435 ; CHECK-LABEL: @test_and_chain_select_ule(
437 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
438 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
439 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
440 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
441 ; CHECK-NEXT: [[AND_1:%.*]] = select i1 [[C_1]], i1 [[C_1]], i1 false
442 ; CHECK-NEXT: [[AND_2:%.*]] = select i1 [[AND_1]], i1 [[C_3]], i1 false
443 ; CHECK-NEXT: [[AND_3:%.*]] = select i1 [[C_4]], i1 [[AND_2]], i1 false
444 ; CHECK-NEXT: br i1 [[AND_3]], label [[BB1:%.*]], label [[EXIT:%.*]]
446 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
447 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], true
448 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
449 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[T_3]]
450 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], true
451 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], true
452 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
453 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
454 ; CHECK-NEXT: ret i1 [[R_5]]
456 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
457 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
458 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
459 ; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
460 ; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
461 ; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
462 ; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
463 ; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
464 ; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
465 ; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
466 ; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
467 ; CHECK-NEXT: ret i1 [[R_10]]
470 %c.1 = icmp ule i4 %x, %y
471 %c.2 = icmp ule i4 %y, %z
472 %c.3 = icmp ule i4 3, %x
473 %c.4 = icmp ule i4 3, %a
474 %and.1 = select i1 %c.1, i1 %c.1, i1 false
475 %and.2 = select i1 %and.1, i1 %c.3, i1 false
476 %and.3 = select i1 %c.4, i1 %and.2, i1 false
477 br i1 %and.3, label %bb1, label %exit
480 %t.1 = icmp ule i4 %x, %z
481 %t.2 = icmp ule i4 %x, %y
482 %r.1 = xor i1 %t.1, %t.2
484 %t.3 = icmp ule i4 %y, %z
485 %r.2 = xor i1 %r.1, %t.3
487 %t.4 = icmp ule i4 3, %x
488 %r.3 = xor i1 %r.2, %t.4
490 %t.5 = icmp ule i4 3, %a
491 %r.4 = xor i1 %r.3, %t.5
493 %c.5 = icmp ule i4 %x, %a
494 %r.5 = xor i1 %r.4, %c.5
499 %c.6 = icmp ule i4 %x, %z
500 %c.7 = icmp ule i4 %x, %a
501 %r.6 = xor i1 %c.6, %c.7
503 %c.8 = icmp ule i4 %x, %y
504 %r.7 = xor i1 %r.6, %c.8
506 %c.9 = icmp ule i4 %y, %z
507 %r.8 = xor i1 %r.7, %c.9
509 %c.10 = icmp ule i4 3, %x
510 %r.9 = xor i1 %r.8, %c.10
512 %c.11 = icmp ule i4 3, %a
513 %r.10 = xor i1 %r.9, %c.11
518 define i1 @test_and_chain_select_ule_logical_or(i4 %x, i4 %y, i4 %z, i4 %a) {
519 ; CHECK-LABEL: @test_and_chain_select_ule_logical_or(
521 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i4 [[X:%.*]], [[Y:%.*]]
522 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i4 [[Y]], [[Z:%.*]]
523 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i4 3, [[X]]
524 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i4 3, [[A:%.*]]
525 ; CHECK-NEXT: [[AND_1:%.*]] = select i1 [[C_1]], i1 [[C_1]], i1 false
526 ; CHECK-NEXT: [[AND_2:%.*]] = select i1 [[AND_1]], i1 [[C_3]], i1 false
527 ; CHECK-NEXT: [[AND_3:%.*]] = select i1 [[C_4]], i1 [[AND_2]], i1 false
528 ; CHECK-NEXT: [[AND_4:%.*]] = select i1 [[AND_3]], i1 true, i1 false
529 ; CHECK-NEXT: br i1 [[AND_4]], label [[BB1:%.*]], label [[EXIT:%.*]]
531 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i4 [[X]], [[Z]]
532 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i4 [[X]], [[Y]]
533 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], [[T_2]]
534 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i4 [[Y]], [[Z]]
535 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[T_3]]
536 ; CHECK-NEXT: [[T_4:%.*]] = icmp ule i4 3, [[X]]
537 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[T_4]]
538 ; CHECK-NEXT: [[T_5:%.*]] = icmp ule i4 3, [[A]]
539 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[R_3]], [[T_5]]
540 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i4 [[X]], [[A]]
541 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
542 ; CHECK-NEXT: ret i1 [[R_5]]
544 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i4 [[X]], [[Z]]
545 ; CHECK-NEXT: [[C_7:%.*]] = icmp ule i4 [[X]], [[A]]
546 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[C_6]], [[C_7]]
547 ; CHECK-NEXT: [[C_8:%.*]] = icmp ule i4 [[X]], [[Y]]
548 ; CHECK-NEXT: [[R_7:%.*]] = xor i1 [[R_6]], [[C_8]]
549 ; CHECK-NEXT: [[C_9:%.*]] = icmp ule i4 [[Y]], [[Z]]
550 ; CHECK-NEXT: [[R_8:%.*]] = xor i1 [[R_7]], [[C_9]]
551 ; CHECK-NEXT: [[C_10:%.*]] = icmp ule i4 3, [[X]]
552 ; CHECK-NEXT: [[R_9:%.*]] = xor i1 [[R_8]], [[C_10]]
553 ; CHECK-NEXT: [[C_11:%.*]] = icmp ule i4 3, [[A]]
554 ; CHECK-NEXT: [[R_10:%.*]] = xor i1 [[R_9]], [[C_11]]
555 ; CHECK-NEXT: ret i1 [[R_10]]
558 %c.1 = icmp ule i4 %x, %y
559 %c.2 = icmp ule i4 %y, %z
560 %c.3 = icmp ule i4 3, %x
561 %c.4 = icmp ule i4 3, %a
562 %and.1 = select i1 %c.1, i1 %c.1, i1 false
563 %and.2 = select i1 %and.1, i1 %c.3, i1 false
564 %and.3 = select i1 %c.4, i1 %and.2, i1 false
565 %and.4 = select i1 %and.3, i1 true, i1 false
566 br i1 %and.4, label %bb1, label %exit
569 %t.1 = icmp ule i4 %x, %z
570 %t.2 = icmp ule i4 %x, %y
571 %r.1 = xor i1 %t.1, %t.2
573 %t.3 = icmp ule i4 %y, %z
574 %r.2 = xor i1 %r.1, %t.3
576 %t.4 = icmp ule i4 3, %x
577 %r.3 = xor i1 %r.2, %t.4
579 %t.5 = icmp ule i4 3, %a
580 %r.4 = xor i1 %r.3, %t.5
582 %c.5 = icmp ule i4 %x, %a
583 %r.5 = xor i1 %r.4, %c.5
588 %c.6 = icmp ule i4 %x, %z
589 %c.7 = icmp ule i4 %x, %a
590 %r.6 = xor i1 %c.6, %c.7
592 %c.8 = icmp ule i4 %x, %y
593 %r.7 = xor i1 %r.6, %c.8
595 %c.9 = icmp ule i4 %y, %z
596 %r.8 = xor i1 %r.7, %c.9
598 %c.10 = icmp ule i4 3, %x
599 %r.9 = xor i1 %r.8, %c.10
601 %c.11 = icmp ule i4 3, %a
602 %r.10 = xor i1 %r.9, %c.11