1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define i1 @bool_true_or_false(i1 %cond) {
5 ; CHECK-LABEL: @bool_true_or_false(
6 ; CHECK-NEXT: ret i1 [[COND:%.*]]
8 %s = select i1 %cond, i1 true, i1 false
12 define <2 x i1> @bool_true_or_false_vec(<2 x i1> %cond) {
13 ; CHECK-LABEL: @bool_true_or_false_vec(
14 ; CHECK-NEXT: ret <2 x i1> [[COND:%.*]]
16 %s = select <2 x i1> %cond, <2 x i1> <i1 true, i1 true>, <2 x i1> zeroinitializer
20 define <2 x i1> @bool_true_or_false_vec_undef(<2 x i1> %cond) {
21 ; CHECK-LABEL: @bool_true_or_false_vec_undef(
22 ; CHECK-NEXT: ret <2 x i1> [[COND:%.*]]
24 %s = select <2 x i1> %cond, <2 x i1> <i1 undef, i1 true>, <2 x i1> <i1 false, i1 undef>
28 define i32 @cond_is_false(i32 %A, i32 %B) {
29 ; CHECK-LABEL: @cond_is_false(
30 ; CHECK-NEXT: ret i32 [[B:%.*]]
32 %C = select i1 false, i32 %A, i32 %B
36 define i32 @cond_is_true(i32 %A, i32 %B) {
37 ; CHECK-LABEL: @cond_is_true(
38 ; CHECK-NEXT: ret i32 [[A:%.*]]
40 %C = select i1 true, i32 %A, i32 %B
44 define i32 @equal_arms(i1 %cond, i32 %x) {
45 ; CHECK-LABEL: @equal_arms(
46 ; CHECK-NEXT: ret i32 [[X:%.*]]
48 %V = select i1 %cond, i32 %x, i32 %x
52 define <2 x i32> @equal_arms_vec(<2 x i1> %cond, <2 x i32> %x) {
53 ; CHECK-LABEL: @equal_arms_vec(
54 ; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
56 %V = select <2 x i1> %cond, <2 x i32> %x, <2 x i32> %x
60 define <2 x i32> @equal_arms_vec_undef(<2 x i1> %cond) {
61 ; CHECK-LABEL: @equal_arms_vec_undef(
62 ; CHECK-NEXT: ret <2 x i32> <i32 42, i32 42>
64 %V = select <2 x i1> %cond, <2 x i32> <i32 42, i32 undef>, <2 x i32> <i32 undef, i32 42>
68 define <3 x float> @equal_arms_vec_less_undef(<3 x i1> %cond) {
69 ; CHECK-LABEL: @equal_arms_vec_less_undef(
70 ; CHECK-NEXT: ret <3 x float> <float 4.200000e+01, float 4.200000e+01, float 4.300000e+01>
72 %V = select <3 x i1> %cond, <3 x float> <float 42.0, float undef, float 43.0>, <3 x float> <float 42.0, float 42.0, float 43.0>
76 define <3 x float> @equal_arms_vec_more_undef(<3 x i1> %cond) {
77 ; CHECK-LABEL: @equal_arms_vec_more_undef(
78 ; CHECK-NEXT: ret <3 x float> <float 4.200000e+01, float undef, float 4.300000e+01>
80 %V = select <3 x i1> %cond, <3 x float> <float 42.0, float undef, float undef>, <3 x float> <float undef, float undef, float 43.0>
84 define <2 x i8> @vsel_tvec(<2 x i8> %x, <2 x i8> %y) {
85 ; CHECK-LABEL: @vsel_tvec(
86 ; CHECK-NEXT: ret <2 x i8> [[X:%.*]]
88 %s = select <2 x i1><i1 true, i1 true>, <2 x i8> %x, <2 x i8> %y
92 define <2 x i8> @vsel_fvec(<2 x i8> %x, <2 x i8> %y) {
93 ; CHECK-LABEL: @vsel_fvec(
94 ; CHECK-NEXT: ret <2 x i8> [[Y:%.*]]
96 %s = select <2 x i1><i1 false, i1 false>, <2 x i8> %x, <2 x i8> %y
100 define <2 x i8> @vsel_mixedvec() {
101 ; CHECK-LABEL: @vsel_mixedvec(
102 ; CHECK-NEXT: ret <2 x i8> <i8 0, i8 3>
104 %s = select <2 x i1><i1 true, i1 false>, <2 x i8> <i8 0, i8 1>, <2 x i8> <i8 2, i8 3>
108 define <3 x i8> @vsel_undef_true_op(<3 x i8> %x, <3 x i8> %y) {
109 ; CHECK-LABEL: @vsel_undef_true_op(
110 ; CHECK-NEXT: ret <3 x i8> [[X:%.*]]
112 %s = select <3 x i1><i1 1, i1 undef, i1 1>, <3 x i8> %x, <3 x i8> %y
116 define <3 x i4> @vsel_undef_false_op(<3 x i4> %x, <3 x i4> %y) {
117 ; CHECK-LABEL: @vsel_undef_false_op(
118 ; CHECK-NEXT: ret <3 x i4> [[Y:%.*]]
120 %s = select <3 x i1><i1 0, i1 undef, i1 undef>, <3 x i4> %x, <3 x i4> %y
124 define i32 @test1(i32 %x) {
125 ; CHECK-LABEL: @test1(
126 ; CHECK-NEXT: ret i32 [[X:%.*]]
129 %cmp = icmp eq i32 %and, 0
130 %and1 = and i32 %x, -2
131 %and1.x = select i1 %cmp, i32 %and1, i32 %x
135 define i32 @test2(i32 %x) {
136 ; CHECK-LABEL: @test2(
137 ; CHECK-NEXT: ret i32 [[X:%.*]]
140 %cmp = icmp ne i32 %and, 0
141 %and1 = and i32 %x, -2
142 %and1.x = select i1 %cmp, i32 %x, i32 %and1
146 define i32 @test3(i32 %x) {
147 ; CHECK-LABEL: @test3(
148 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[X:%.*]], -2
149 ; CHECK-NEXT: ret i32 [[AND1]]
152 %cmp = icmp ne i32 %and, 0
153 %and1 = and i32 %x, -2
154 %and1.x = select i1 %cmp, i32 %and1, i32 %x
158 define i32 @test4(i32 %X) {
159 ; CHECK-LABEL: @test4(
160 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
161 ; CHECK-NEXT: ret i32 [[OR]]
163 %cmp = icmp slt i32 %X, 0
164 %or = or i32 %X, -2147483648
165 %cond = select i1 %cmp, i32 %X, i32 %or
169 ; Same as above, but the compare isn't canonical
170 define i32 @test4noncanon(i32 %X) {
171 ; CHECK-LABEL: @test4noncanon(
172 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
173 ; CHECK-NEXT: ret i32 [[OR]]
175 %cmp = icmp sle i32 %X, -1
176 %or = or i32 %X, -2147483648
177 %cond = select i1 %cmp, i32 %X, i32 %or
181 define i32 @test5(i32 %X) {
182 ; CHECK-LABEL: @test5(
183 ; CHECK-NEXT: ret i32 [[X:%.*]]
185 %cmp = icmp slt i32 %X, 0
186 %or = or i32 %X, -2147483648
187 %cond = select i1 %cmp, i32 %or, i32 %X
191 define i32 @test6(i32 %X) {
192 ; CHECK-LABEL: @test6(
193 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
194 ; CHECK-NEXT: ret i32 [[AND]]
196 %cmp = icmp slt i32 %X, 0
197 %and = and i32 %X, 2147483647
198 %cond = select i1 %cmp, i32 %and, i32 %X
202 define i32 @test7(i32 %X) {
203 ; CHECK-LABEL: @test7(
204 ; CHECK-NEXT: ret i32 [[X:%.*]]
206 %cmp = icmp slt i32 %X, 0
207 %and = and i32 %X, 2147483647
208 %cond = select i1 %cmp, i32 %X, i32 %and
212 define i32 @test8(i32 %X) {
213 ; CHECK-LABEL: @test8(
214 ; CHECK-NEXT: ret i32 [[X:%.*]]
216 %cmp = icmp sgt i32 %X, -1
217 %or = or i32 %X, -2147483648
218 %cond = select i1 %cmp, i32 %X, i32 %or
222 define i32 @test9(i32 %X) {
223 ; CHECK-LABEL: @test9(
224 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
225 ; CHECK-NEXT: ret i32 [[OR]]
227 %cmp = icmp sgt i32 %X, -1
228 %or = or i32 %X, -2147483648
229 %cond = select i1 %cmp, i32 %or, i32 %X
233 ; Same as above, but the compare isn't canonical
234 define i32 @test9noncanon(i32 %X) {
235 ; CHECK-LABEL: @test9noncanon(
236 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
237 ; CHECK-NEXT: ret i32 [[OR]]
239 %cmp = icmp sge i32 %X, 0
240 %or = or i32 %X, -2147483648
241 %cond = select i1 %cmp, i32 %or, i32 %X
245 define i32 @test10(i32 %X) {
246 ; CHECK-LABEL: @test10(
247 ; CHECK-NEXT: ret i32 [[X:%.*]]
249 %cmp = icmp sgt i32 %X, -1
250 %and = and i32 %X, 2147483647
251 %cond = select i1 %cmp, i32 %and, i32 %X
255 define i32 @test11(i32 %X) {
256 ; CHECK-LABEL: @test11(
257 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
258 ; CHECK-NEXT: ret i32 [[AND]]
260 %cmp = icmp sgt i32 %X, -1
261 %and = and i32 %X, 2147483647
262 %cond = select i1 %cmp, i32 %X, i32 %and
266 define <2 x i8> @test11vec(<2 x i8> %X) {
267 ; CHECK-LABEL: @test11vec(
268 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i8> [[X:%.*]], <i8 127, i8 127>
269 ; CHECK-NEXT: ret <2 x i8> [[AND]]
271 %cmp = icmp sgt <2 x i8> %X, <i8 -1, i8 -1>
272 %and = and <2 x i8> %X, <i8 127, i8 127>
273 %sel = select <2 x i1> %cmp, <2 x i8> %X, <2 x i8> %and
277 define i32 @test12(i32 %X) {
278 ; CHECK-LABEL: @test12(
279 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 3
280 ; CHECK-NEXT: ret i32 [[AND]]
282 %cmp = icmp ult i32 %X, 4
284 %cond = select i1 %cmp, i32 %X, i32 %and
288 ; Same as above, but the compare isn't canonical
289 define i32 @test12noncanon(i32 %X) {
290 ; CHECK-LABEL: @test12noncanon(
291 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 3
292 ; CHECK-NEXT: ret i32 [[AND]]
294 %cmp = icmp ule i32 %X, 3
296 %cond = select i1 %cmp, i32 %X, i32 %and
300 define i32 @test13(i32 %X) {
301 ; CHECK-LABEL: @test13(
302 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 3
303 ; CHECK-NEXT: ret i32 [[AND]]
305 %cmp = icmp ugt i32 %X, 3
307 %cond = select i1 %cmp, i32 %and, i32 %X
311 ; Same as above, but the compare isn't canonical
312 define i32 @test13noncanon(i32 %X) {
313 ; CHECK-LABEL: @test13noncanon(
314 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 3
315 ; CHECK-NEXT: ret i32 [[AND]]
317 %cmp = icmp uge i32 %X, 4
319 %cond = select i1 %cmp, i32 %and, i32 %X
323 define i32 @select_icmp_and_8_eq_0_or_8(i32 %x) {
324 ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8(
325 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 8
326 ; CHECK-NEXT: ret i32 [[OR]]
329 %cmp = icmp eq i32 %and, 0
331 %sel = select i1 %cmp, i32 %or, i32 %x
335 define i32 @select_icmp_and_8_eq_0_or_8_alt(i32 %x) {
336 ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8_alt(
337 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 8
338 ; CHECK-NEXT: ret i32 [[OR]]
341 %cmp = icmp ne i32 %and, 0
343 %sel = select i1 %cmp, i32 %x, i32 %or
347 define i32 @select_icmp_and_8_ne_0_or_8(i32 %x) {
348 ; CHECK-LABEL: @select_icmp_and_8_ne_0_or_8(
349 ; CHECK-NEXT: ret i32 [[X:%.*]]
352 %cmp = icmp ne i32 %and, 0
354 %sel = select i1 %cmp, i32 %or, i32 %x
358 define i32 @select_icmp_and_8_ne_0_or_8_alt(i32 %x) {
359 ; CHECK-LABEL: @select_icmp_and_8_ne_0_or_8_alt(
360 ; CHECK-NEXT: ret i32 [[X:%.*]]
363 %cmp = icmp eq i32 %and, 0
365 %sel = select i1 %cmp, i32 %x, i32 %or
369 define i32 @select_icmp_and_8_eq_0_and_not_8(i32 %x) {
370 ; CHECK-LABEL: @select_icmp_and_8_eq_0_and_not_8(
371 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[X:%.*]], -9
372 ; CHECK-NEXT: ret i32 [[AND1]]
375 %cmp = icmp eq i32 %and, 0
376 %and1 = and i32 %x, -9
377 %sel = select i1 %cmp, i32 %x, i32 %and1
381 define i32 @select_icmp_and_8_eq_0_and_not_8_alt(i32 %x) {
382 ; CHECK-LABEL: @select_icmp_and_8_eq_0_and_not_8_alt(
383 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[X:%.*]], -9
384 ; CHECK-NEXT: ret i32 [[AND1]]
387 %cmp = icmp ne i32 %and, 0
388 %and1 = and i32 %x, -9
389 %sel = select i1 %cmp, i32 %and1, i32 %x
393 define i32 @select_icmp_and_8_ne_0_and_not_8(i32 %x) {
394 ; CHECK-LABEL: @select_icmp_and_8_ne_0_and_not_8(
395 ; CHECK-NEXT: ret i32 [[X:%.*]]
398 %cmp = icmp ne i32 %and, 0
399 %and1 = and i32 %x, -9
400 %sel = select i1 %cmp, i32 %x, i32 %and1
404 define i32 @select_icmp_and_8_ne_0_and_not_8_alt(i32 %x) {
405 ; CHECK-LABEL: @select_icmp_and_8_ne_0_and_not_8_alt(
406 ; CHECK-NEXT: ret i32 [[X:%.*]]
409 %cmp = icmp eq i32 %and, 0
410 %and1 = and i32 %x, -9
411 %sel = select i1 %cmp, i32 %and1, i32 %x
415 ; PR28466: https://llvm.org/bugs/show_bug.cgi?id=28466
416 ; Each of the previous 8 patterns has a variant that replaces the
417 ; 'and' with a 'trunc' and the icmp eq/ne with icmp slt/sgt.
419 define i32 @select_icmp_trunc_8_ne_0_or_128(i32 %x) {
420 ; CHECK-LABEL: @select_icmp_trunc_8_ne_0_or_128(
421 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 128
422 ; CHECK-NEXT: ret i32 [[OR]]
424 %trunc = trunc i32 %x to i8
425 %cmp = icmp sgt i8 %trunc, -1
427 %sel = select i1 %cmp, i32 %or, i32 %x
431 define i32 @select_icmp_trunc_8_ne_0_or_128_alt(i32 %x) {
432 ; CHECK-LABEL: @select_icmp_trunc_8_ne_0_or_128_alt(
433 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 128
434 ; CHECK-NEXT: ret i32 [[OR]]
436 %trunc = trunc i32 %x to i8
437 %cmp = icmp slt i8 %trunc, 0
439 %sel = select i1 %cmp, i32 %x, i32 %or
443 define i32 @select_icmp_trunc_8_eq_0_or_128(i32 %x) {
444 ; CHECK-LABEL: @select_icmp_trunc_8_eq_0_or_128(
445 ; CHECK-NEXT: ret i32 [[X:%.*]]
447 %trunc = trunc i32 %x to i8
448 %cmp = icmp slt i8 %trunc, 0
450 %sel = select i1 %cmp, i32 %or, i32 %x
454 define i32 @select_icmp_trunc_8_eq_0_or_128_alt(i32 %x) {
455 ; CHECK-LABEL: @select_icmp_trunc_8_eq_0_or_128_alt(
456 ; CHECK-NEXT: ret i32 [[X:%.*]]
458 %trunc = trunc i32 %x to i8
459 %cmp = icmp sgt i8 %trunc, -1
461 %sel = select i1 %cmp, i32 %x, i32 %or
465 define i32 @select_icmp_trunc_8_eq_0_and_not_8(i32 %x) {
466 ; CHECK-LABEL: @select_icmp_trunc_8_eq_0_and_not_8(
467 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], -9
468 ; CHECK-NEXT: ret i32 [[AND]]
470 %trunc = trunc i32 %x to i4
471 %cmp = icmp sgt i4 %trunc, -1
472 %and = and i32 %x, -9
473 %sel = select i1 %cmp, i32 %x, i32 %and
477 define i32 @select_icmp_trunc_8_eq_0_and_not_8_alt(i32 %x) {
478 ; CHECK-LABEL: @select_icmp_trunc_8_eq_0_and_not_8_alt(
479 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], -9
480 ; CHECK-NEXT: ret i32 [[AND]]
482 %trunc = trunc i32 %x to i4
483 %cmp = icmp slt i4 %trunc, 0
484 %and = and i32 %x, -9
485 %sel = select i1 %cmp, i32 %and, i32 %x
489 define i32 @select_icmp_trunc_8_ne_0_and_not_8(i32 %x) {
490 ; CHECK-LABEL: @select_icmp_trunc_8_ne_0_and_not_8(
491 ; CHECK-NEXT: ret i32 [[X:%.*]]
493 %trunc = trunc i32 %x to i4
494 %cmp = icmp slt i4 %trunc, 0
495 %and = and i32 %x, -9
496 %sel = select i1 %cmp, i32 %x, i32 %and
500 define i32 @select_icmp_trunc_8_ne_0_and_not_8_alt(i32 %x) {
501 ; CHECK-LABEL: @select_icmp_trunc_8_ne_0_and_not_8_alt(
502 ; CHECK-NEXT: ret i32 [[X:%.*]]
504 %trunc = trunc i32 %x to i4
505 %cmp = icmp sgt i4 %trunc, -1
506 %and = and i32 %x, -9
507 %sel = select i1 %cmp, i32 %and, i32 %x
511 ; Make sure that at least a few of the same patterns are repeated with vector types.
513 define <2 x i32> @select_icmp_and_8_ne_0_and_not_8_vec(<2 x i32> %x) {
514 ; CHECK-LABEL: @select_icmp_and_8_ne_0_and_not_8_vec(
515 ; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
517 %and = and <2 x i32> %x, <i32 8, i32 8>
518 %cmp = icmp ne <2 x i32> %and, zeroinitializer
519 %and1 = and <2 x i32> %x, <i32 -9, i32 -9>
520 %sel = select <2 x i1> %cmp, <2 x i32> %x, <2 x i32> %and1
524 define <2 x i32> @select_icmp_trunc_8_ne_0_and_not_8_alt_vec(<2 x i32> %x) {
525 ; CHECK-LABEL: @select_icmp_trunc_8_ne_0_and_not_8_alt_vec(
526 ; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
528 %trunc = trunc <2 x i32> %x to <2 x i4>
529 %cmp = icmp sgt <2 x i4> %trunc, <i4 -1, i4 -1>
530 %and = and <2 x i32> %x, <i32 -9, i32 -9>
531 %sel = select <2 x i1> %cmp, <2 x i32> %and, <2 x i32> %x
535 ; Insert a bit from x into y? This should be possible in InstCombine, but not InstSimplify?
537 define i32 @select_icmp_x_and_8_eq_0_y_and_not_8(i32 %x, i32 %y) {
538 ; CHECK-LABEL: @select_icmp_x_and_8_eq_0_y_and_not_8(
539 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 8
540 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 0
541 ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y:%.*]], -9
542 ; CHECK-NEXT: [[Y_AND1:%.*]] = select i1 [[CMP]], i32 [[Y]], i32 [[AND1]]
543 ; CHECK-NEXT: ret i32 [[Y_AND1]]
546 %cmp = icmp eq i32 %and, 0
547 %and1 = and i32 %y, -9
548 %y.and1 = select i1 %cmp, i32 %y, i32 %and1
552 define i64 @select_icmp_x_and_8_eq_0_y64_and_not_8(i32 %x, i64 %y) {
553 ; CHECK-LABEL: @select_icmp_x_and_8_eq_0_y64_and_not_8(
554 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 8
555 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 0
556 ; CHECK-NEXT: [[AND1:%.*]] = and i64 [[Y:%.*]], -9
557 ; CHECK-NEXT: [[Y_AND1:%.*]] = select i1 [[CMP]], i64 [[Y]], i64 [[AND1]]
558 ; CHECK-NEXT: ret i64 [[Y_AND1]]
561 %cmp = icmp eq i32 %and, 0
562 %and1 = and i64 %y, -9
563 %y.and1 = select i1 %cmp, i64 %y, i64 %and1
567 define i64 @select_icmp_x_and_8_ne_0_y64_and_not_8(i32 %x, i64 %y) {
568 ; CHECK-LABEL: @select_icmp_x_and_8_ne_0_y64_and_not_8(
569 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 8
570 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 0
571 ; CHECK-NEXT: [[AND1:%.*]] = and i64 [[Y:%.*]], -9
572 ; CHECK-NEXT: [[AND1_Y:%.*]] = select i1 [[CMP]], i64 [[AND1]], i64 [[Y]]
573 ; CHECK-NEXT: ret i64 [[AND1_Y]]
576 %cmp = icmp eq i32 %and, 0
577 %and1 = and i64 %y, -9
578 %and1.y = select i1 %cmp, i64 %and1, i64 %y
582 ; Don't crash on a pointer or aggregate type.
584 define i32* @select_icmp_pointers(i32* %x, i32* %y) {
585 ; CHECK-LABEL: @select_icmp_pointers(
586 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32* [[X:%.*]], null
587 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32* [[X]], i32* [[Y:%.*]]
588 ; CHECK-NEXT: ret i32* [[SEL]]
590 %cmp = icmp slt i32* %x, null
591 %sel = select i1 %cmp, i32* %x, i32* %y
595 ; If the condition is known, we don't need to select, but we're not
596 ; doing this fold here to avoid compile-time cost.
598 declare void @llvm.assume(i1)
600 define i8 @assume_sel_cond(i1 %cond, i8 %x, i8 %y) {
601 ; CHECK-LABEL: @assume_sel_cond(
602 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND:%.*]])
603 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X:%.*]], i8 [[Y:%.*]]
604 ; CHECK-NEXT: ret i8 [[SEL]]
606 call void @llvm.assume(i1 %cond)
607 %sel = select i1 %cond, i8 %x, i8 %y
611 define i8 @do_not_assume_sel_cond(i1 %cond, i8 %x, i8 %y) {
612 ; CHECK-LABEL: @do_not_assume_sel_cond(
613 ; CHECK-NEXT: [[NOTCOND:%.*]] = icmp eq i1 [[COND:%.*]], false
614 ; CHECK-NEXT: call void @llvm.assume(i1 [[NOTCOND]])
615 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND]], i8 [[X:%.*]], i8 [[Y:%.*]]
616 ; CHECK-NEXT: ret i8 [[SEL]]
618 %notcond = icmp eq i1 %cond, false
619 call void @llvm.assume(i1 %notcond)
620 %sel = select i1 %cond, i8 %x, i8 %y
624 define i32* @select_icmp_eq_0_gep_operand(i32* %base, i64 %n) {
625 ; CHECK-LABEL: @select_icmp_eq_0_gep_operand(
626 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, i32* [[BASE:%.*]], i64 [[N:%.*]]
627 ; CHECK-NEXT: ret i32* [[GEP]]
629 %cond = icmp eq i64 %n, 0
630 %gep = getelementptr i32, i32* %base, i64 %n
631 %r = select i1 %cond, i32* %base, i32* %gep
635 define i32* @select_icmp_ne_0_gep_operand(i32* %base, i64 %n) {
636 ; CHECK-LABEL: @select_icmp_ne_0_gep_operand(
637 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, i32* [[BASE:%.*]], i64 [[N:%.*]]
638 ; CHECK-NEXT: ret i32* [[GEP]]
640 %cond = icmp ne i64 %n, 0
641 %gep = getelementptr i32, i32* %base, i64 %n
642 %r = select i1 %cond, i32* %gep, i32* %base
646 define i1 @and_cmps(i32 %x) {
647 ; CHECK-LABEL: @and_cmps(
648 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], 92
649 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], 11
650 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 false
651 ; CHECK-NEXT: ret i1 [[R]]
653 %cmp1 = icmp slt i32 %x, 92
654 %cmp2 = icmp slt i32 %x, 11
655 %r = select i1 %cmp1, i1 %cmp2, i1 false
659 define <2 x i1> @and_cmps_vector(<2 x i32> %x) {
660 ; CHECK-LABEL: @and_cmps_vector(
661 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt <2 x i32> [[X:%.*]], <i32 92, i32 92>
662 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt <2 x i32> [[X]], <i32 11, i32 11>
663 ; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[CMP1]], <2 x i1> [[CMP2]], <2 x i1> zeroinitializer
664 ; CHECK-NEXT: ret <2 x i1> [[R]]
666 %cmp1 = icmp slt <2 x i32> %x, <i32 92, i32 92>
667 %cmp2 = icmp slt <2 x i32> %x, <i32 11, i32 11>
668 %r = select <2 x i1> %cmp1, <2 x i1> %cmp2, <2 x i1> <i1 false, i1 false>
672 define i1 @or_cmps(float %x) {
673 ; CHECK-LABEL: @or_cmps(
674 ; CHECK-NEXT: [[CMP1:%.*]] = fcmp uno float [[X:%.*]], 4.200000e+01
675 ; CHECK-NEXT: [[CMP2:%.*]] = fcmp uno float [[X]], 5.200000e+01
676 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP1]], i1 true, i1 [[CMP2]]
677 ; CHECK-NEXT: ret i1 [[R]]
679 %cmp1 = fcmp uno float %x, 42.0
680 %cmp2 = fcmp uno float %x, 52.0
681 %r = select i1 %cmp1, i1 true, i1 %cmp2
685 define <2 x i1> @or_logic_vector(<2 x i1> %x, <2 x i1> %y) {
686 ; CHECK-LABEL: @or_logic_vector(
687 ; CHECK-NEXT: [[A:%.*]] = and <2 x i1> [[X:%.*]], [[Y:%.*]]
688 ; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[X]], <2 x i1> <i1 true, i1 true>, <2 x i1> [[A]]
689 ; CHECK-NEXT: ret <2 x i1> [[R]]
691 %a = and <2 x i1> %x, %y
692 %r = select <2 x i1> %x, <2 x i1> <i1 true, i1 true>, <2 x i1> %a
696 define i1 @and_not_cmps(i32 %x) {
697 ; CHECK-LABEL: @and_not_cmps(
698 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], 92
699 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], 11
700 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP1]], i1 false, i1 [[CMP2]]
701 ; CHECK-NEXT: ret i1 [[R]]
703 %cmp1 = icmp slt i32 %x, 92
704 %cmp2 = icmp slt i32 %x, 11
705 %r = select i1 %cmp1, i1 false, i1 %cmp2
709 define i1 @or_not_cmps(i32 %x) {
710 ; CHECK-LABEL: @or_not_cmps(
711 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], 92
712 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], 11
713 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP1]], i1 [[CMP2]], i1 true
714 ; CHECK-NEXT: ret i1 [[R]]
716 %cmp1 = icmp slt i32 %x, 92
717 %cmp2 = icmp slt i32 %x, 11
718 %r = select i1 %cmp1, i1 %cmp2, i1 true
722 define i8 @and_cmps_wrong_type(i32 %x) {
723 ; CHECK-LABEL: @and_cmps_wrong_type(
724 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[X:%.*]], 92
725 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i32 [[X]], 11
726 ; CHECK-NEXT: [[S:%.*]] = sext i1 [[CMP2]] to i8
727 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP1]], i8 [[S]], i8 0
728 ; CHECK-NEXT: ret i8 [[R]]
730 %cmp1 = icmp slt i32 %x, 92
731 %cmp2 = icmp slt i32 %x, 11
732 %s = sext i1 %cmp2 to i8
733 %r = select i1 %cmp1, i8 %s, i8 0
737 define i1 @y_might_be_poison(float %x, float %y) {
738 ; CHECK-LABEL: @y_might_be_poison(
739 ; CHECK-NEXT: [[C1:%.*]] = fcmp ord float 0.000000e+00, [[X:%.*]]
740 ; CHECK-NEXT: [[C2:%.*]] = fcmp ord float [[X]], [[Y:%.*]]
741 ; CHECK-NEXT: [[C3:%.*]] = select i1 [[C1]], i1 [[C2]], i1 false
742 ; CHECK-NEXT: ret i1 [[C3]]
744 %c1 = fcmp ord float 0.0, %x
745 %c2 = fcmp ord float %x, %y
746 %c3 = select i1 %c1, i1 %c2, i1 false
750 ; Negative tests to ensure we don't remove selects with undef true/false values.
751 ; See https://bugs.llvm.org/show_bug.cgi?id=31633
752 ; https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html
753 ; https://reviews.llvm.org/D83360
754 define i32 @false_undef(i1 %cond, i32 %x) {
755 ; CHECK-LABEL: @false_undef(
756 ; CHECK-NEXT: [[S:%.*]] = select i1 [[COND:%.*]], i32 [[X:%.*]], i32 undef
757 ; CHECK-NEXT: ret i32 [[S]]
759 %s = select i1 %cond, i32 %x, i32 undef
763 define i32 @true_undef(i1 %cond, i32 %x) {
764 ; CHECK-LABEL: @true_undef(
765 ; CHECK-NEXT: [[S:%.*]] = select i1 [[COND:%.*]], i32 undef, i32 [[X:%.*]]
766 ; CHECK-NEXT: ret i32 [[S]]
768 %s = select i1 %cond, i32 undef, i32 %x
772 define <2 x i32> @false_undef_vec(i1 %cond, <2 x i32> %x) {
773 ; CHECK-LABEL: @false_undef_vec(
774 ; CHECK-NEXT: [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> [[X:%.*]], <2 x i32> undef
775 ; CHECK-NEXT: ret <2 x i32> [[S]]
777 %s = select i1 %cond, <2 x i32> %x, <2 x i32> undef
781 define <2 x i32> @true_undef_vec(i1 %cond, <2 x i32> %x) {
782 ; CHECK-LABEL: @true_undef_vec(
783 ; CHECK-NEXT: [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> undef, <2 x i32> [[X:%.*]]
784 ; CHECK-NEXT: ret <2 x i32> [[S]]
786 %s = select i1 %cond, <2 x i32> undef, <2 x i32> %x
790 ; These can be folded because the other value is guaranteed not to be poison.
791 define i32 @false_undef_true_constant(i1 %cond) {
792 ; CHECK-LABEL: @false_undef_true_constant(
793 ; CHECK-NEXT: ret i32 10
795 %s = select i1 %cond, i32 10, i32 undef
799 define i32 @true_undef_false_constant(i1 %cond) {
800 ; CHECK-LABEL: @true_undef_false_constant(
801 ; CHECK-NEXT: ret i32 20
803 %s = select i1 %cond, i32 undef, i32 20
807 define <2 x i32> @false_undef_true_constant_vec(i1 %cond) {
808 ; CHECK-LABEL: @false_undef_true_constant_vec(
809 ; CHECK-NEXT: ret <2 x i32> <i32 42, i32 -42>
811 %s = select i1 %cond, <2 x i32> <i32 42, i32 -42>, <2 x i32> undef
815 define <2 x i32> @true_undef_false_constant_vec(i1 %cond) {
816 ; CHECK-LABEL: @true_undef_false_constant_vec(
817 ; CHECK-NEXT: ret <2 x i32> <i32 -42, i32 42>
819 %s = select i1 %cond, <2 x i32> undef, <2 x i32> <i32 -42, i32 42>
823 ; If one input is undef and the other is freeze, we can fold it to the freeze.
824 define i32 @false_undef_true_freeze(i1 %cond, i32 %x) {
825 ; CHECK-LABEL: @false_undef_true_freeze(
826 ; CHECK-NEXT: [[XF:%.*]] = freeze i32 [[X:%.*]]
827 ; CHECK-NEXT: ret i32 [[XF]]
830 %s = select i1 %cond, i32 %xf, i32 undef
834 define i32 @false_undef_false_freeze(i1 %cond, i32 %x) {
835 ; CHECK-LABEL: @false_undef_false_freeze(
836 ; CHECK-NEXT: [[XF:%.*]] = freeze i32 [[X:%.*]]
837 ; CHECK-NEXT: ret i32 [[XF]]
840 %s = select i1 %cond, i32 undef, i32 %xf
844 @g = external global i32, align 1
846 define <2 x i32> @false_undef_true_constextpr_vec(i1 %cond) {
847 ; CHECK-LABEL: @false_undef_true_constextpr_vec(
848 ; CHECK-NEXT: ret <2 x i32> <i32 ptrtoint (i32* @g to i32), i32 ptrtoint (i32* @g to i32)>
850 %s = select i1 %cond, <2 x i32> <i32 undef, i32 ptrtoint (i32* @g to i32)>, <2 x i32> <i32 ptrtoint (i32* @g to i32), i32 undef>
854 define i32 @all_constant_true_undef() {
855 ; CHECK-LABEL: @all_constant_true_undef(
856 ; CHECK-NEXT: ret i32 1
858 %s = select i1 ptrtoint (i32 ()* @all_constant_true_undef to i1), i32 undef, i32 1
862 define float @all_constant_false_undef() {
863 ; CHECK-LABEL: @all_constant_false_undef(
864 ; CHECK-NEXT: ret float 1.000000e+00
866 %s = select i1 ptrtoint (float ()* @all_constant_false_undef to i1), float undef, float 1.0
870 define <2 x i32> @all_constant_true_undef_vec() {
871 ; CHECK-LABEL: @all_constant_true_undef_vec(
872 ; CHECK-NEXT: ret <2 x i32> <i32 1, i32 -1>
874 %s = select i1 ptrtoint (<2 x i32> ()* @all_constant_true_undef_vec to i1), <2 x i32> undef, <2 x i32> <i32 1, i32 -1>
878 define <2 x float> @all_constant_false_undef_vec() {
879 ; CHECK-LABEL: @all_constant_false_undef_vec(
880 ; CHECK-NEXT: ret <2 x float> <float 1.000000e+00, float -1.000000e+00>
882 %s = select i1 ptrtoint (<2 x float> ()* @all_constant_false_undef_vec to i1), <2 x float> undef, <2 x float> <float 1.0, float -1.0>
886 ; Negative tests. Don't fold if the non-undef operand is a constexpr.
887 define i32 @all_constant_false_undef_true_constexpr() {
888 ; CHECK-LABEL: @all_constant_false_undef_true_constexpr(
889 ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i1), i32 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i32), i32 undef
890 ; CHECK-NEXT: ret i32 [[S]]
892 %s = select i1 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i1), i32 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i32), i32 undef
896 define i32 @all_constant_true_undef_false_constexpr() {
897 ; CHECK-LABEL: @all_constant_true_undef_false_constexpr(
898 ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i1), i32 undef, i32 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i32)
899 ; CHECK-NEXT: ret i32 [[S]]
901 %s = select i1 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i1), i32 undef, i32 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i32)
905 ; Negative tests. Don't fold if the non-undef operand is a vector containing a constexpr.
906 define <2 x i32> @all_constant_false_undef_true_constexpr_vec() {
907 ; CHECK-LABEL: @all_constant_false_undef_true_constexpr_vec(
908 ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i1), <2 x i32> <i32 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i32), i32 -1>, <2 x i32> undef
909 ; CHECK-NEXT: ret <2 x i32> [[S]]
911 %s = select i1 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i1), <2 x i32> <i32 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i32), i32 -1>, <2 x i32> undef
915 define <2 x i32> @all_constant_true_undef_false_constexpr_vec() {
916 ; CHECK-LABEL: @all_constant_true_undef_false_constexpr_vec(
917 ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i1), <2 x i32> undef, <2 x i32> <i32 -1, i32 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i32)>
918 ; CHECK-NEXT: ret <2 x i32> [[S]]
920 %s = select i1 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i1), <2 x i32> undef, <2 x i32><i32 -1, i32 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i32)>
924 define i1 @expand_binop_undef(i32 %x, i32 %y) {
925 ; CHECK-LABEL: @expand_binop_undef(
926 ; CHECK-NEXT: [[CMP9_NOT_1:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
927 ; CHECK-NEXT: [[CMP15:%.*]] = icmp slt i32 [[X]], [[Y]]
928 ; CHECK-NEXT: [[SPEC_SELECT39:%.*]] = select i1 [[CMP9_NOT_1]], i1 undef, i1 [[CMP15]]
929 ; CHECK-NEXT: [[SPEC_SELECT40:%.*]] = xor i1 [[CMP9_NOT_1]], true
930 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = and i1 [[SPEC_SELECT39]], [[SPEC_SELECT40]]
931 ; CHECK-NEXT: ret i1 [[SPEC_SELECT]]
933 %cmp9.not.1 = icmp eq i32 %x, %y
934 %cmp15 = icmp slt i32 %x, %y
935 %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15
936 %spec.select40 = xor i1 %cmp9.not.1, 1
937 %spec.select = and i1 %spec.select39, %spec.select40
941 define i32 @pr47322_more_poisonous_replacement(i32 %arg) {
942 ; CHECK-LABEL: @pr47322_more_poisonous_replacement(
943 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARG:%.*]], 0
944 ; CHECK-NEXT: [[TRAILING:%.*]] = call i32 @llvm.cttz.i32(i32 [[ARG]], i1 immarg true)
945 ; CHECK-NEXT: [[SHIFTED:%.*]] = lshr i32 [[ARG]], [[TRAILING]]
946 ; CHECK-NEXT: [[R1_SROA_0_1:%.*]] = select i1 [[CMP]], i32 0, i32 [[SHIFTED]]
947 ; CHECK-NEXT: ret i32 [[R1_SROA_0_1]]
949 %cmp = icmp eq i32 %arg, 0
950 %trailing = call i32 @llvm.cttz.i32(i32 %arg, i1 immarg true)
951 %shifted = lshr i32 %arg, %trailing
952 %r1.sroa.0.1 = select i1 %cmp, i32 0, i32 %shifted
955 declare i32 @llvm.cttz.i32(i32, i1 immarg)
957 ; Partial undef scalable vectors should be ignored.
958 define <vscale x 2 x i1> @ignore_scalable_undef(<vscale x 2 x i1> %cond) {
959 ; CHECK-LABEL: @ignore_scalable_undef(
960 ; CHECK-NEXT: ret <vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0)
962 %vec = insertelement <vscale x 2 x i1> undef, i1 true, i32 0
963 %s = select <vscale x 2 x i1> %cond, <vscale x 2 x i1> undef, <vscale x 2 x i1> %vec
964 ret <vscale x 2 x i1> %s
967 define i32 @select_neutral_add_rhs(i32 %x, i32 %y) {
968 ; CHECK-LABEL: @select_neutral_add_rhs(
969 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
970 ; CHECK-NEXT: ret i32 [[ADD]]
972 %cmp = icmp ne i32 %y, 0
973 %add = add i32 %x, %y
974 %sel = select i1 %cmp, i32 %add, i32 %x
978 define i32 @select_neutral_add_lhs(i32 %x, i32 %y) {
979 ; CHECK-LABEL: @select_neutral_add_lhs(
980 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[Y:%.*]], [[X:%.*]]
981 ; CHECK-NEXT: ret i32 [[ADD]]
983 %cmp = icmp ne i32 %y, 0
984 %add = add i32 %y, %x
985 %sel = select i1 %cmp, i32 %add, i32 %x
989 define i32 @select_neutral_sub_rhs(i32 %x, i32 %y) {
990 ; CHECK-LABEL: @select_neutral_sub_rhs(
991 ; CHECK-NEXT: [[ADD:%.*]] = sub i32 [[X:%.*]], [[Y:%.*]]
992 ; CHECK-NEXT: ret i32 [[ADD]]
994 %cmp = icmp ne i32 %y, 0
995 %add = sub i32 %x, %y
996 %sel = select i1 %cmp, i32 %add, i32 %x
1000 define i32 @select_neutral_sub_lhs(i32 %x, i32 %y) {
1001 ; CHECK-LABEL: @select_neutral_sub_lhs(
1002 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[Y:%.*]], 0
1003 ; CHECK-NEXT: [[ADD:%.*]] = sub i32 [[Y]], [[X:%.*]]
1004 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 [[X]]
1005 ; CHECK-NEXT: ret i32 [[SEL]]
1007 %cmp = icmp ne i32 %y, 0
1008 %add = sub i32 %y, %x
1009 %sel = select i1 %cmp, i32 %add, i32 %x
1013 define i32 @select_ctpop_zero(i32 %x) {
1014 ; CHECK-LABEL: @select_ctpop_zero(
1015 ; CHECK-NEXT: [[T1:%.*]] = call i32 @llvm.ctpop.i32(i32 [[X:%.*]])
1016 ; CHECK-NEXT: ret i32 [[T1]]
1018 %t0 = icmp eq i32 %x, 0
1019 %t1 = call i32 @llvm.ctpop.i32(i32 %x)
1020 %sel = select i1 %t0, i32 0, i32 %t1
1023 declare i32 @llvm.ctpop.i32(i32)
1025 define <2 x i32> @vec_select_no_equivalence(<2 x i32> %x, <2 x i32> %y) {
1026 ; CHECK-LABEL: @vec_select_no_equivalence(
1027 ; CHECK-NEXT: [[X10:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> undef, <2 x i32> <i32 1, i32 0>
1028 ; CHECK-NEXT: [[COND:%.*]] = icmp eq <2 x i32> [[X]], zeroinitializer
1029 ; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND]], <2 x i32> [[X10]], <2 x i32> zeroinitializer
1030 ; CHECK-NEXT: ret <2 x i32> [[S]]
1032 %x10 = shufflevector <2 x i32> %x, <2 x i32> undef, <2 x i32> <i32 1, i32 0>
1033 %cond = icmp eq <2 x i32> %x, zeroinitializer
1034 %s = select <2 x i1> %cond, <2 x i32> %x10, <2 x i32> zeroinitializer
1038 define i32 @poison(i32 %x, i32 %y) {
1039 ; CHECK-LABEL: @poison(
1040 ; CHECK-NEXT: ret i32 [[X:%.*]]
1042 %v = select i1 undef, i32 %x, i32 %y
1046 define i32 @poison2(i1 %cond, i32 %x) {
1047 ; CHECK-LABEL: @poison2(
1048 ; CHECK-NEXT: ret i32 [[X:%.*]]
1050 %v = select i1 %cond, i32 poison, i32 %x
1054 define i32 @poison3(i1 %cond, i32 %x) {
1055 ; CHECK-LABEL: @poison3(
1056 ; CHECK-NEXT: ret i32 [[X:%.*]]
1058 %v = select i1 %cond, i32 %x, i32 poison
1062 define <2 x i32> @poison4(<2 x i1> %cond, <2 x i32> %x) {
1063 ; CHECK-LABEL: @poison4(
1064 ; CHECK-NEXT: ret <2 x i32> [[X:%.*]]
1066 %v = select <2 x i1> %cond, <2 x i32> %x, <2 x i32> poison