1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=SSE --check-prefix=SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefix=SSE --check-prefix=SSE41
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=AVX --check-prefix=AVX1
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=AVX --check-prefix=AVX2
7 ; Verify that we don't emit packed vector shifts instructions if the
8 ; condition used by the vector select is a vector of constants.
10 define <4 x float> @test1(<4 x float> %a, <4 x float> %b) {
13 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[1,3]
14 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2,1,3]
19 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3]
24 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3]
26 %1 = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x float> %a, <4 x float> %b
30 define <4 x float> @test2(<4 x float> %a, <4 x float> %b) {
33 ; SSE2-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
34 ; SSE2-NEXT: movapd %xmm1, %xmm0
39 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
44 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
46 %1 = select <4 x i1> <i1 true, i1 true, i1 false, i1 false>, <4 x float> %a, <4 x float> %b
50 define <4 x float> @test3(<4 x float> %a, <4 x float> %b) {
53 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
58 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
63 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
65 %1 = select <4 x i1> <i1 false, i1 false, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
69 define <4 x float> @test4(<4 x float> %a, <4 x float> %b) {
72 ; SSE-NEXT: movaps %xmm1, %xmm0
77 ; AVX-NEXT: vmovaps %xmm1, %xmm0
79 %1 = select <4 x i1> <i1 false, i1 false, i1 false, i1 false>, <4 x float> %a, <4 x float> %b
83 define <4 x float> @test5(<4 x float> %a, <4 x float> %b) {
91 %1 = select <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
95 define <8 x i16> @test6(<8 x i16> %a, <8 x i16> %b) {
103 %1 = select <8 x i1> <i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false>, <8 x i16> %a, <8 x i16> %a
107 define <8 x i16> @test7(<8 x i16> %a, <8 x i16> %b) {
110 ; SSE2-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
111 ; SSE2-NEXT: movapd %xmm1, %xmm0
114 ; SSE41-LABEL: test7:
116 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
121 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
123 %1 = select <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false>, <8 x i16> %a, <8 x i16> %b
127 define <8 x i16> @test8(<8 x i16> %a, <8 x i16> %b) {
130 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
133 ; SSE41-LABEL: test8:
135 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
140 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
142 %1 = select <8 x i1> <i1 false, i1 false, i1 false, i1 false, i1 true, i1 true, i1 true, i1 true>, <8 x i16> %a, <8 x i16> %b
146 define <8 x i16> @test9(<8 x i16> %a, <8 x i16> %b) {
149 ; SSE-NEXT: movaps %xmm1, %xmm0
154 ; AVX-NEXT: vmovaps %xmm1, %xmm0
156 %1 = select <8 x i1> <i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <8 x i16> %a, <8 x i16> %b
160 define <8 x i16> @test10(<8 x i16> %a, <8 x i16> %b) {
168 %1 = select <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <8 x i16> %a, <8 x i16> %b
172 define <8 x i16> @test11(<8 x i16> %a, <8 x i16> %b) {
173 ; SSE2-LABEL: test11:
175 ; SSE2-NEXT: movaps {{.*#+}} xmm2 = [0,65535,65535,0,0,65535,65535,0]
176 ; SSE2-NEXT: andps %xmm2, %xmm0
177 ; SSE2-NEXT: andnps %xmm1, %xmm2
178 ; SSE2-NEXT: orps %xmm2, %xmm0
181 ; SSE41-LABEL: test11:
183 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0],xmm0[1,2],xmm1[3,4],xmm0[5,6],xmm1[7]
188 ; AVX-NEXT: vpblendw {{.*#+}} xmm0 = xmm1[0],xmm0[1,2],xmm1[3,4],xmm0[5,6],xmm1[7]
190 %1 = select <8 x i1> <i1 false, i1 true, i1 true, i1 false, i1 undef, i1 true, i1 true, i1 undef>, <8 x i16> %a, <8 x i16> %b
194 define <8 x i16> @test12(<8 x i16> %a, <8 x i16> %b) {
197 ; SSE-NEXT: movaps %xmm1, %xmm0
202 ; AVX-NEXT: vmovaps %xmm1, %xmm0
204 %1 = select <8 x i1> <i1 false, i1 false, i1 undef, i1 false, i1 false, i1 false, i1 false, i1 undef>, <8 x i16> %a, <8 x i16> %b
208 define <8 x i16> @test13(<8 x i16> %a, <8 x i16> %b) {
211 ; SSE-NEXT: movaps %xmm1, %xmm0
216 ; AVX-NEXT: vmovaps %xmm1, %xmm0
218 %1 = select <8 x i1> <i1 undef, i1 undef, i1 undef, i1 undef, i1 undef, i1 undef, i1 undef, i1 undef>, <8 x i16> %a, <8 x i16> %b
222 ; Fold (vselect (build_vector AllOnes), N1, N2) -> N1
223 define <4 x float> @test14(<4 x float> %a, <4 x float> %b) {
231 %1 = select <4 x i1> <i1 true, i1 undef, i1 true, i1 undef>, <4 x float> %a, <4 x float> %b
235 define <8 x i16> @test15(<8 x i16> %a, <8 x i16> %b) {
243 %1 = select <8 x i1> <i1 true, i1 true, i1 true, i1 undef, i1 undef, i1 true, i1 true, i1 undef>, <8 x i16> %a, <8 x i16> %b
247 ; Fold (vselect (build_vector AllZeros), N1, N2) -> N2
248 define <4 x float> @test16(<4 x float> %a, <4 x float> %b) {
251 ; SSE-NEXT: movaps %xmm1, %xmm0
256 ; AVX-NEXT: vmovaps %xmm1, %xmm0
258 %1 = select <4 x i1> <i1 false, i1 undef, i1 false, i1 undef>, <4 x float> %a, <4 x float> %b
262 define <8 x i16> @test17(<8 x i16> %a, <8 x i16> %b) {
265 ; SSE-NEXT: movaps %xmm1, %xmm0
270 ; AVX-NEXT: vmovaps %xmm1, %xmm0
272 %1 = select <8 x i1> <i1 false, i1 false, i1 false, i1 undef, i1 undef, i1 false, i1 false, i1 undef>, <8 x i16> %a, <8 x i16> %b
276 define <4 x float> @test18(<4 x float> %a, <4 x float> %b) {
277 ; SSE2-LABEL: test18:
279 ; SSE2-NEXT: movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
282 ; SSE41-LABEL: test18:
284 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
289 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
291 %1 = select <4 x i1> <i1 false, i1 true, i1 true, i1 true>, <4 x float> %a, <4 x float> %b
295 define <4 x i32> @test19(<4 x i32> %a, <4 x i32> %b) {
296 ; SSE2-LABEL: test19:
298 ; SSE2-NEXT: movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
301 ; SSE41-LABEL: test19:
303 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
308 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
310 %1 = select <4 x i1> <i1 false, i1 true, i1 true, i1 true>, <4 x i32> %a, <4 x i32> %b
314 define <2 x double> @test20(<2 x double> %a, <2 x double> %b) {
315 ; SSE2-LABEL: test20:
317 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
320 ; SSE41-LABEL: test20:
322 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
327 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
329 %1 = select <2 x i1> <i1 false, i1 true>, <2 x double> %a, <2 x double> %b
333 define <2 x i64> @test21(<2 x i64> %a, <2 x i64> %b) {
334 ; SSE2-LABEL: test21:
336 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
339 ; SSE41-LABEL: test21:
341 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
346 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
348 %1 = select <2 x i1> <i1 false, i1 true>, <2 x i64> %a, <2 x i64> %b
352 define <4 x float> @test22(<4 x float> %a, <4 x float> %b) {
353 ; SSE2-LABEL: test22:
355 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
356 ; SSE2-NEXT: movaps %xmm1, %xmm0
359 ; SSE41-LABEL: test22:
361 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
366 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
368 %1 = select <4 x i1> <i1 true, i1 false, i1 false, i1 false>, <4 x float> %a, <4 x float> %b
372 define <4 x i32> @test23(<4 x i32> %a, <4 x i32> %b) {
373 ; SSE2-LABEL: test23:
375 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
376 ; SSE2-NEXT: movaps %xmm1, %xmm0
379 ; SSE41-LABEL: test23:
381 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
386 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
388 %1 = select <4 x i1> <i1 true, i1 false, i1 false, i1 false>, <4 x i32> %a, <4 x i32> %b
392 define <2 x double> @test24(<2 x double> %a, <2 x double> %b) {
393 ; SSE2-LABEL: test24:
395 ; SSE2-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
396 ; SSE2-NEXT: movapd %xmm1, %xmm0
399 ; SSE41-LABEL: test24:
401 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
406 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
408 %1 = select <2 x i1> <i1 true, i1 false>, <2 x double> %a, <2 x double> %b
412 define <2 x i64> @test25(<2 x i64> %a, <2 x i64> %b) {
413 ; SSE2-LABEL: test25:
415 ; SSE2-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
416 ; SSE2-NEXT: movapd %xmm1, %xmm0
419 ; SSE41-LABEL: test25:
421 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
426 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
428 %1 = select <2 x i1> <i1 true, i1 false>, <2 x i64> %a, <2 x i64> %b
432 define <4 x float> @select_of_shuffles_0(<2 x float> %a0, <2 x float> %b0, <2 x float> %a1, <2 x float> %b1) {
433 ; SSE-LABEL: select_of_shuffles_0:
435 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm2[0]
436 ; SSE-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0],xmm3[0]
437 ; SSE-NEXT: subps %xmm1, %xmm0
440 ; AVX-LABEL: select_of_shuffles_0:
442 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm2[0]
443 ; AVX-NEXT: vmovlhps {{.*#+}} xmm1 = xmm1[0],xmm3[0]
444 ; AVX-NEXT: vsubps %xmm1, %xmm0, %xmm0
446 %1 = shufflevector <2 x float> %a0, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
447 %2 = shufflevector <2 x float> %a1, <2 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
448 %3 = select <4 x i1> <i1 false, i1 false, i1 true, i1 true>, <4 x float> %2, <4 x float> %1
449 %4 = shufflevector <2 x float> %b0, <2 x float> undef, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
450 %5 = shufflevector <2 x float> %b1, <2 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 0, i32 1>
451 %6 = select <4 x i1> <i1 false, i1 false, i1 true, i1 true>, <4 x float> %5, <4 x float> %4
452 %7 = fsub <4 x float> %3, %6
457 define <16 x double> @select_illegal(<16 x double> %a, <16 x double> %b) {
458 ; SSE-LABEL: select_illegal:
460 ; SSE-NEXT: movq %rdi, %rax
461 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm4
462 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm5
463 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm6
464 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm7
465 ; SSE-NEXT: movaps %xmm7, 112(%rdi)
466 ; SSE-NEXT: movaps %xmm6, 96(%rdi)
467 ; SSE-NEXT: movaps %xmm5, 80(%rdi)
468 ; SSE-NEXT: movaps %xmm4, 64(%rdi)
469 ; SSE-NEXT: movaps %xmm3, 48(%rdi)
470 ; SSE-NEXT: movaps %xmm2, 32(%rdi)
471 ; SSE-NEXT: movaps %xmm1, 16(%rdi)
472 ; SSE-NEXT: movaps %xmm0, (%rdi)
475 ; AVX-LABEL: select_illegal:
477 ; AVX-NEXT: vmovaps %ymm7, %ymm3
478 ; AVX-NEXT: vmovaps %ymm6, %ymm2
480 %sel = select <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <16 x double> %a, <16 x double> %b
481 ret <16 x double> %sel
484 ; Make sure we can optimize the condition MSB when it is used by 2 selects.
485 ; The v2i1 here will be passed as v2i64 and we will emit a sign_extend_inreg to fill the upper bits.
486 ; We should be able to remove the sra from the sign_extend_inreg to leave only shl.
487 define <2 x i64> @shrunkblend_2uses(<2 x i1> %cond, <2 x i64> %a, <2 x i64> %b, <2 x i64> %c, <2 x i64> %d) {
488 ; SSE2-LABEL: shrunkblend_2uses:
490 ; SSE2-NEXT: psllq $63, %xmm0
491 ; SSE2-NEXT: psrad $31, %xmm0
492 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
493 ; SSE2-NEXT: movdqa %xmm0, %xmm5
494 ; SSE2-NEXT: pandn %xmm2, %xmm5
495 ; SSE2-NEXT: pand %xmm0, %xmm1
496 ; SSE2-NEXT: por %xmm1, %xmm5
497 ; SSE2-NEXT: pand %xmm0, %xmm3
498 ; SSE2-NEXT: pandn %xmm4, %xmm0
499 ; SSE2-NEXT: por %xmm3, %xmm0
500 ; SSE2-NEXT: paddq %xmm5, %xmm0
503 ; SSE41-LABEL: shrunkblend_2uses:
505 ; SSE41-NEXT: psllq $63, %xmm0
506 ; SSE41-NEXT: blendvpd %xmm0, %xmm1, %xmm2
507 ; SSE41-NEXT: blendvpd %xmm0, %xmm3, %xmm4
508 ; SSE41-NEXT: paddq %xmm2, %xmm4
509 ; SSE41-NEXT: movdqa %xmm4, %xmm0
512 ; AVX-LABEL: shrunkblend_2uses:
514 ; AVX-NEXT: vpsllq $63, %xmm0, %xmm0
515 ; AVX-NEXT: vblendvpd %xmm0, %xmm1, %xmm2, %xmm1
516 ; AVX-NEXT: vblendvpd %xmm0, %xmm3, %xmm4, %xmm0
517 ; AVX-NEXT: vpaddq %xmm0, %xmm1, %xmm0
519 %x = select <2 x i1> %cond, <2 x i64> %a, <2 x i64> %b
520 %y = select <2 x i1> %cond, <2 x i64> %c, <2 x i64> %d
521 %z = add <2 x i64> %x, %y
525 ; Similar to above, but condition has a use that isn't a condition of a vselect so we can't optimize.
526 define <2 x i64> @shrunkblend_nonvselectuse(<2 x i1> %cond, <2 x i64> %a, <2 x i64> %b, <2 x i64> %c, <2 x i64> %d) {
527 ; SSE2-LABEL: shrunkblend_nonvselectuse:
529 ; SSE2-NEXT: psllq $63, %xmm0
530 ; SSE2-NEXT: psrad $31, %xmm0
531 ; SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm0[1,1,3,3]
532 ; SSE2-NEXT: movdqa %xmm3, %xmm0
533 ; SSE2-NEXT: pandn %xmm2, %xmm0
534 ; SSE2-NEXT: pand %xmm3, %xmm1
535 ; SSE2-NEXT: por %xmm1, %xmm0
536 ; SSE2-NEXT: paddq %xmm3, %xmm0
539 ; SSE41-LABEL: shrunkblend_nonvselectuse:
541 ; SSE41-NEXT: psllq $63, %xmm0
542 ; SSE41-NEXT: psrad $31, %xmm0
543 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
544 ; SSE41-NEXT: blendvpd %xmm0, %xmm1, %xmm2
545 ; SSE41-NEXT: paddq %xmm2, %xmm0
548 ; AVX-LABEL: shrunkblend_nonvselectuse:
550 ; AVX-NEXT: vpsllq $63, %xmm0, %xmm0
551 ; AVX-NEXT: vpxor %xmm3, %xmm3, %xmm3
552 ; AVX-NEXT: vpcmpgtq %xmm0, %xmm3, %xmm0
553 ; AVX-NEXT: vblendvpd %xmm0, %xmm1, %xmm2, %xmm1
554 ; AVX-NEXT: vpaddq %xmm0, %xmm1, %xmm0
556 %x = select <2 x i1> %cond, <2 x i64> %a, <2 x i64> %b
557 %y = sext <2 x i1> %cond to <2 x i64>
558 %z = add <2 x i64> %x, %y
562 ; This turns into a SHRUNKBLEND with SSE4 or later, and via
563 ; late shuffle magic, both sides of the blend are the same
564 ; value. If that is not simplified before isel, it can fail
567 define <2 x i32> @simplify_select(i32 %x, <2 x i1> %z) {
568 ; SSE2-LABEL: simplify_select:
570 ; SSE2-NEXT: # kill: def $edi killed $edi def $rdi
571 ; SSE2-NEXT: psllq $63, %xmm0
572 ; SSE2-NEXT: psrad $31, %xmm0
573 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
574 ; SSE2-NEXT: movq %rdi, %xmm1
575 ; SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm1[0,1,0,1]
576 ; SSE2-NEXT: movdqa %xmm2, %xmm3
577 ; SSE2-NEXT: punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm1[0]
578 ; SSE2-NEXT: pand %xmm0, %xmm2
579 ; SSE2-NEXT: pandn %xmm3, %xmm0
580 ; SSE2-NEXT: por %xmm2, %xmm0
583 ; SSE41-LABEL: simplify_select:
585 ; SSE41-NEXT: # kill: def $edi killed $edi def $rdi
586 ; SSE41-NEXT: movq %rdi, %xmm0
587 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
590 ; AVX1-LABEL: simplify_select:
592 ; AVX1-NEXT: # kill: def $edi killed $edi def $rdi
593 ; AVX1-NEXT: vmovq %rdi, %xmm0
594 ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
597 ; AVX2-LABEL: simplify_select:
599 ; AVX2-NEXT: # kill: def $edi killed $edi def $rdi
600 ; AVX2-NEXT: vmovq %rdi, %xmm0
601 ; AVX2-NEXT: vpbroadcastq %xmm0, %xmm0
603 %a = insertelement <2 x i32> <i32 0, i32 undef>, i32 %x, i32 1
604 %b = insertelement <2 x i32> <i32 undef, i32 0>, i32 %x, i32 0
605 %y = or <2 x i32> %a, %b
606 %p16 = extractelement <2 x i32> %y, i32 1
607 %p17 = insertelement <2 x i32> undef, i32 %p16, i32 0
608 %p18 = insertelement <2 x i32> %p17, i32 %x, i32 1
609 %r = select <2 x i1> %z, <2 x i32> %y, <2 x i32> %p18
613 ; Test to make sure we don't try to insert a new setcc to swap the operands
614 ; of select with all zeros LHS if the setcc has additional users.
615 define void @vselect_allzeros_LHS_multiple_use_setcc(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z, <4 x i32>* %p1, <4 x i32>* %p2) {
616 ; SSE-LABEL: vselect_allzeros_LHS_multiple_use_setcc:
618 ; SSE-NEXT: movdqa {{.*#+}} xmm3 = [1,2,4,8]
619 ; SSE-NEXT: pand %xmm3, %xmm0
620 ; SSE-NEXT: pcmpeqd %xmm3, %xmm0
621 ; SSE-NEXT: movdqa %xmm0, %xmm3
622 ; SSE-NEXT: pandn %xmm1, %xmm3
623 ; SSE-NEXT: pand %xmm2, %xmm0
624 ; SSE-NEXT: movdqa %xmm3, (%rdi)
625 ; SSE-NEXT: movdqa %xmm0, (%rsi)
628 ; AVX-LABEL: vselect_allzeros_LHS_multiple_use_setcc:
630 ; AVX-NEXT: vmovdqa {{.*#+}} xmm3 = [1,2,4,8]
631 ; AVX-NEXT: vpand %xmm3, %xmm0, %xmm0
632 ; AVX-NEXT: vpcmpeqd %xmm3, %xmm0, %xmm0
633 ; AVX-NEXT: vpandn %xmm1, %xmm0, %xmm1
634 ; AVX-NEXT: vpand %xmm2, %xmm0, %xmm0
635 ; AVX-NEXT: vmovdqa %xmm1, (%rdi)
636 ; AVX-NEXT: vmovdqa %xmm0, (%rsi)
638 %and = and <4 x i32> %x, <i32 1, i32 2, i32 4, i32 8>
639 %cond = icmp ne <4 x i32> %and, zeroinitializer
640 %sel1 = select <4 x i1> %cond, <4 x i32> zeroinitializer, <4 x i32> %y
641 %sel2 = select <4 x i1> %cond, <4 x i32> %z, <4 x i32> zeroinitializer
642 store <4 x i32> %sel1, <4 x i32>* %p1
643 store <4 x i32> %sel2, <4 x i32>* %p2