1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mcpu=x86-64 -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE,SSE2
3 ; RUN: llc < %s -mcpu=x86-64 -mattr=+ssse3 | FileCheck %s --check-prefixes=CHECK,SSE,SSSE3
4 ; RUN: llc < %s -mcpu=x86-64 -mattr=+sse4.1 | FileCheck %s --check-prefixes=CHECK,SSE,SSE41
5 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX,AVX1
6 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX,AVX2,AVX2-SLOW
7 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx2,+fast-variable-shuffle | FileCheck %s --check-prefixes=CHECK,AVX,AVX2,AVX2-FAST
9 ; Verify that the DAG combiner correctly folds bitwise operations across
10 ; shuffles, nested shuffles with undef, pairs of nested shuffles, and other
11 ; basic and always-safe patterns. Also test that the DAG combiner will combine
12 ; target-specific shuffle instructions where reasonable.
14 target triple = "x86_64-unknown-unknown"
16 declare <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32>, i8)
17 declare <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16>, i8)
18 declare <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16>, i8)
20 define <4 x i32> @combine_pshufd1(<4 x i32> %a) {
21 ; CHECK-LABEL: combine_pshufd1:
22 ; CHECK: # %bb.0: # %entry
25 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27)
26 %c = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %b, i8 27)
30 define <4 x i32> @combine_pshufd2(<4 x i32> %a) {
31 ; CHECK-LABEL: combine_pshufd2:
32 ; CHECK: # %bb.0: # %entry
35 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27)
36 %b.cast = bitcast <4 x i32> %b to <8 x i16>
37 %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b.cast, i8 -28)
38 %c.cast = bitcast <8 x i16> %c to <4 x i32>
39 %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 27)
43 define <4 x i32> @combine_pshufd3(<4 x i32> %a) {
44 ; CHECK-LABEL: combine_pshufd3:
45 ; CHECK: # %bb.0: # %entry
48 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 27)
49 %b.cast = bitcast <4 x i32> %b to <8 x i16>
50 %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b.cast, i8 -28)
51 %c.cast = bitcast <8 x i16> %c to <4 x i32>
52 %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 27)
56 define <4 x i32> @combine_pshufd4(<4 x i32> %a) {
57 ; SSE-LABEL: combine_pshufd4:
58 ; SSE: # %bb.0: # %entry
59 ; SSE-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
62 ; AVX-LABEL: combine_pshufd4:
63 ; AVX: # %bb.0: # %entry
64 ; AVX-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
67 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 -31)
68 %b.cast = bitcast <4 x i32> %b to <8 x i16>
69 %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b.cast, i8 27)
70 %c.cast = bitcast <8 x i16> %c to <4 x i32>
71 %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 -31)
75 define <4 x i32> @combine_pshufd5(<4 x i32> %a) {
76 ; SSE-LABEL: combine_pshufd5:
77 ; SSE: # %bb.0: # %entry
78 ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
81 ; AVX-LABEL: combine_pshufd5:
82 ; AVX: # %bb.0: # %entry
83 ; AVX-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
86 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 -76)
87 %b.cast = bitcast <4 x i32> %b to <8 x i16>
88 %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b.cast, i8 27)
89 %c.cast = bitcast <8 x i16> %c to <4 x i32>
90 %d = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %c.cast, i8 -76)
94 define <4 x i32> @combine_pshufd6(<4 x i32> %a) {
95 ; SSE-LABEL: combine_pshufd6:
96 ; SSE: # %bb.0: # %entry
97 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,0,0,0]
100 ; AVX1-LABEL: combine_pshufd6:
101 ; AVX1: # %bb.0: # %entry
102 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
105 ; AVX2-LABEL: combine_pshufd6:
106 ; AVX2: # %bb.0: # %entry
107 ; AVX2-NEXT: vbroadcastss %xmm0, %xmm0
110 %b = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %a, i8 0)
111 %c = call <4 x i32> @llvm.x86.sse2.pshuf.d(<4 x i32> %b, i8 8)
115 define <8 x i16> @combine_pshuflw1(<8 x i16> %a) {
116 ; CHECK-LABEL: combine_pshuflw1:
117 ; CHECK: # %bb.0: # %entry
120 %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27)
121 %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b, i8 27)
125 define <8 x i16> @combine_pshuflw2(<8 x i16> %a) {
126 ; CHECK-LABEL: combine_pshuflw2:
127 ; CHECK: # %bb.0: # %entry
130 %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27)
131 %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b, i8 -28)
132 %d = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %c, i8 27)
136 define <8 x i16> @combine_pshuflw3(<8 x i16> %a) {
137 ; SSE-LABEL: combine_pshuflw3:
138 ; SSE: # %bb.0: # %entry
139 ; SSE-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
142 ; AVX-LABEL: combine_pshuflw3:
143 ; AVX: # %bb.0: # %entry
144 ; AVX-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,7,6,5,4]
147 %b = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %a, i8 27)
148 %c = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %b, i8 27)
149 %d = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %c, i8 27)
153 define <8 x i16> @combine_pshufhw1(<8 x i16> %a) {
154 ; SSE-LABEL: combine_pshufhw1:
155 ; SSE: # %bb.0: # %entry
156 ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
159 ; AVX-LABEL: combine_pshufhw1:
160 ; AVX: # %bb.0: # %entry
161 ; AVX-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[3,2,1,0,4,5,6,7]
164 %b = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %a, i8 27)
165 %c = call <8 x i16> @llvm.x86.sse2.pshufl.w(<8 x i16> %b, i8 27)
166 %d = call <8 x i16> @llvm.x86.sse2.pshufh.w(<8 x i16> %c, i8 27)
170 define <4 x i32> @combine_bitwise_ops_test1(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
171 ; SSE-LABEL: combine_bitwise_ops_test1:
173 ; SSE-NEXT: pand %xmm1, %xmm0
174 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
177 ; AVX-LABEL: combine_bitwise_ops_test1:
179 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
180 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
182 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
183 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
184 %and = and <4 x i32> %shuf1, %shuf2
188 define <4 x i32> @combine_bitwise_ops_test2(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
189 ; SSE-LABEL: combine_bitwise_ops_test2:
191 ; SSE-NEXT: por %xmm1, %xmm0
192 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
195 ; AVX-LABEL: combine_bitwise_ops_test2:
197 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
198 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
200 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
201 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
202 %or = or <4 x i32> %shuf1, %shuf2
206 define <4 x i32> @combine_bitwise_ops_test3(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
207 ; SSE-LABEL: combine_bitwise_ops_test3:
209 ; SSE-NEXT: pxor %xmm1, %xmm0
210 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
213 ; AVX-LABEL: combine_bitwise_ops_test3:
215 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
216 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
218 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
219 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 1, i32 3>
220 %xor = xor <4 x i32> %shuf1, %shuf2
224 define <4 x i32> @combine_bitwise_ops_test4(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
225 ; SSE-LABEL: combine_bitwise_ops_test4:
227 ; SSE-NEXT: pand %xmm1, %xmm0
228 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
231 ; AVX-LABEL: combine_bitwise_ops_test4:
233 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
234 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
236 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7>
237 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7>
238 %and = and <4 x i32> %shuf1, %shuf2
242 define <4 x i32> @combine_bitwise_ops_test5(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
243 ; SSE-LABEL: combine_bitwise_ops_test5:
245 ; SSE-NEXT: por %xmm1, %xmm0
246 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
249 ; AVX-LABEL: combine_bitwise_ops_test5:
251 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
252 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
254 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7>
255 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7>
256 %or = or <4 x i32> %shuf1, %shuf2
260 define <4 x i32> @combine_bitwise_ops_test6(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
261 ; SSE-LABEL: combine_bitwise_ops_test6:
263 ; SSE-NEXT: pxor %xmm1, %xmm0
264 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,1,3]
267 ; AVX-LABEL: combine_bitwise_ops_test6:
269 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
270 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
272 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 4, i32 6, i32 5, i32 7>
273 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 4, i32 6, i32 5, i32 7>
274 %xor = xor <4 x i32> %shuf1, %shuf2
279 ; Verify that DAGCombiner moves the shuffle after the xor/and/or even if shuffles
280 ; are not performing a swizzle operations.
282 define <4 x i32> @combine_bitwise_ops_test1b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
283 ; SSE2-LABEL: combine_bitwise_ops_test1b:
285 ; SSE2-NEXT: pand %xmm1, %xmm0
286 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
287 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[1,3,2,3]
288 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
291 ; SSSE3-LABEL: combine_bitwise_ops_test1b:
293 ; SSSE3-NEXT: pand %xmm1, %xmm0
294 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
295 ; SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm2[1,3,2,3]
296 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
299 ; SSE41-LABEL: combine_bitwise_ops_test1b:
301 ; SSE41-NEXT: andps %xmm1, %xmm0
302 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3]
305 ; AVX-LABEL: combine_bitwise_ops_test1b:
307 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
308 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3]
310 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
311 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
312 %and = and <4 x i32> %shuf1, %shuf2
316 define <4 x i32> @combine_bitwise_ops_test2b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
317 ; SSE2-LABEL: combine_bitwise_ops_test2b:
319 ; SSE2-NEXT: por %xmm1, %xmm0
320 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
321 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[1,3,2,3]
322 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
325 ; SSSE3-LABEL: combine_bitwise_ops_test2b:
327 ; SSSE3-NEXT: por %xmm1, %xmm0
328 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
329 ; SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm2[1,3,2,3]
330 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
333 ; SSE41-LABEL: combine_bitwise_ops_test2b:
335 ; SSE41-NEXT: orps %xmm1, %xmm0
336 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3]
339 ; AVX-LABEL: combine_bitwise_ops_test2b:
341 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
342 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3]
344 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
345 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
346 %or = or <4 x i32> %shuf1, %shuf2
350 define <4 x i32> @combine_bitwise_ops_test3b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
351 ; SSE2-LABEL: combine_bitwise_ops_test3b:
353 ; SSE2-NEXT: xorps %xmm1, %xmm0
354 ; SSE2-NEXT: andps {{.*}}(%rip), %xmm0
357 ; SSSE3-LABEL: combine_bitwise_ops_test3b:
359 ; SSSE3-NEXT: xorps %xmm1, %xmm0
360 ; SSSE3-NEXT: andps {{.*}}(%rip), %xmm0
363 ; SSE41-LABEL: combine_bitwise_ops_test3b:
365 ; SSE41-NEXT: xorps %xmm1, %xmm0
366 ; SSE41-NEXT: xorps %xmm1, %xmm1
367 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3]
370 ; AVX-LABEL: combine_bitwise_ops_test3b:
372 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
373 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
374 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3]
376 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
377 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 5, i32 2, i32 7>
378 %xor = xor <4 x i32> %shuf1, %shuf2
382 define <4 x i32> @combine_bitwise_ops_test4b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
383 ; SSE2-LABEL: combine_bitwise_ops_test4b:
385 ; SSE2-NEXT: pand %xmm1, %xmm0
386 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,3,2,3]
387 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,2,3]
388 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
391 ; SSSE3-LABEL: combine_bitwise_ops_test4b:
393 ; SSSE3-NEXT: pand %xmm1, %xmm0
394 ; SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,3,2,3]
395 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,2,3]
396 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
399 ; SSE41-LABEL: combine_bitwise_ops_test4b:
401 ; SSE41-NEXT: andps %xmm1, %xmm0
402 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3]
405 ; AVX-LABEL: combine_bitwise_ops_test4b:
407 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
408 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3]
410 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7>
411 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7>
412 %and = and <4 x i32> %shuf1, %shuf2
416 define <4 x i32> @combine_bitwise_ops_test5b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
417 ; SSE2-LABEL: combine_bitwise_ops_test5b:
419 ; SSE2-NEXT: por %xmm1, %xmm0
420 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,3,2,3]
421 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,2,3]
422 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
425 ; SSSE3-LABEL: combine_bitwise_ops_test5b:
427 ; SSSE3-NEXT: por %xmm1, %xmm0
428 ; SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,3,2,3]
429 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,2,3]
430 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
433 ; SSE41-LABEL: combine_bitwise_ops_test5b:
435 ; SSE41-NEXT: orps %xmm1, %xmm0
436 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3]
439 ; AVX-LABEL: combine_bitwise_ops_test5b:
441 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
442 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm2[0],xmm0[1],xmm2[2],xmm0[3]
444 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7>
445 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7>
446 %or = or <4 x i32> %shuf1, %shuf2
450 define <4 x i32> @combine_bitwise_ops_test6b(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
451 ; SSE2-LABEL: combine_bitwise_ops_test6b:
453 ; SSE2-NEXT: xorps %xmm1, %xmm0
454 ; SSE2-NEXT: andps {{.*}}(%rip), %xmm0
457 ; SSSE3-LABEL: combine_bitwise_ops_test6b:
459 ; SSSE3-NEXT: xorps %xmm1, %xmm0
460 ; SSSE3-NEXT: andps {{.*}}(%rip), %xmm0
463 ; SSE41-LABEL: combine_bitwise_ops_test6b:
465 ; SSE41-NEXT: xorps %xmm1, %xmm0
466 ; SSE41-NEXT: xorps %xmm1, %xmm1
467 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
470 ; AVX-LABEL: combine_bitwise_ops_test6b:
472 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
473 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
474 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
476 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 5, i32 2, i32 7>
477 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 5, i32 2, i32 7>
478 %xor = xor <4 x i32> %shuf1, %shuf2
482 define <4 x i32> @combine_bitwise_ops_test1c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
483 ; SSE-LABEL: combine_bitwise_ops_test1c:
485 ; SSE-NEXT: andps %xmm1, %xmm0
486 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3]
489 ; AVX-LABEL: combine_bitwise_ops_test1c:
491 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
492 ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3]
494 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
495 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
496 %and = and <4 x i32> %shuf1, %shuf2
500 define <4 x i32> @combine_bitwise_ops_test2c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
501 ; SSE-LABEL: combine_bitwise_ops_test2c:
503 ; SSE-NEXT: orps %xmm1, %xmm0
504 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3]
507 ; AVX-LABEL: combine_bitwise_ops_test2c:
509 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
510 ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[1,3]
512 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
513 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
514 %or = or <4 x i32> %shuf1, %shuf2
518 define <4 x i32> @combine_bitwise_ops_test3c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
519 ; SSE2-LABEL: combine_bitwise_ops_test3c:
521 ; SSE2-NEXT: xorps %xmm1, %xmm0
522 ; SSE2-NEXT: xorps %xmm1, %xmm1
523 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[2,3]
526 ; SSSE3-LABEL: combine_bitwise_ops_test3c:
528 ; SSSE3-NEXT: xorps %xmm1, %xmm0
529 ; SSSE3-NEXT: xorps %xmm1, %xmm1
530 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[2,3]
533 ; SSE41-LABEL: combine_bitwise_ops_test3c:
535 ; SSE41-NEXT: xorps %xmm1, %xmm0
536 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = xmm0[0,2],zero,zero
539 ; AVX-LABEL: combine_bitwise_ops_test3c:
541 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
542 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0,2],zero,zero
544 %shuf1 = shufflevector <4 x i32> %a, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
545 %shuf2 = shufflevector <4 x i32> %b, <4 x i32> %c, <4 x i32><i32 0, i32 2, i32 5, i32 7>
546 %xor = xor <4 x i32> %shuf1, %shuf2
550 define <4 x i32> @combine_bitwise_ops_test4c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
551 ; SSE-LABEL: combine_bitwise_ops_test4c:
553 ; SSE-NEXT: andps %xmm1, %xmm0
554 ; SSE-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3]
555 ; SSE-NEXT: movaps %xmm2, %xmm0
558 ; AVX-LABEL: combine_bitwise_ops_test4c:
560 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
561 ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm2[0,2],xmm0[1,3]
563 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7>
564 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7>
565 %and = and <4 x i32> %shuf1, %shuf2
569 define <4 x i32> @combine_bitwise_ops_test5c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
570 ; SSE-LABEL: combine_bitwise_ops_test5c:
572 ; SSE-NEXT: orps %xmm1, %xmm0
573 ; SSE-NEXT: shufps {{.*#+}} xmm2 = xmm2[0,2],xmm0[1,3]
574 ; SSE-NEXT: movaps %xmm2, %xmm0
577 ; AVX-LABEL: combine_bitwise_ops_test5c:
579 ; AVX-NEXT: vorps %xmm1, %xmm0, %xmm0
580 ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm2[0,2],xmm0[1,3]
582 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7>
583 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7>
584 %or = or <4 x i32> %shuf1, %shuf2
588 define <4 x i32> @combine_bitwise_ops_test6c(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
589 ; SSE2-LABEL: combine_bitwise_ops_test6c:
591 ; SSE2-NEXT: xorps %xmm1, %xmm0
592 ; SSE2-NEXT: xorps %xmm1, %xmm1
593 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,1],xmm0[1,3]
594 ; SSE2-NEXT: movaps %xmm1, %xmm0
597 ; SSSE3-LABEL: combine_bitwise_ops_test6c:
599 ; SSSE3-NEXT: xorps %xmm1, %xmm0
600 ; SSSE3-NEXT: xorps %xmm1, %xmm1
601 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,1],xmm0[1,3]
602 ; SSSE3-NEXT: movaps %xmm1, %xmm0
605 ; SSE41-LABEL: combine_bitwise_ops_test6c:
607 ; SSE41-NEXT: xorps %xmm1, %xmm0
608 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = zero,zero,xmm0[1,3]
611 ; AVX-LABEL: combine_bitwise_ops_test6c:
613 ; AVX-NEXT: vxorps %xmm1, %xmm0, %xmm0
614 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = zero,zero,xmm0[1,3]
616 %shuf1 = shufflevector <4 x i32> %c, <4 x i32> %a, <4 x i32><i32 0, i32 2, i32 5, i32 7>
617 %shuf2 = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32><i32 0, i32 2, i32 5, i32 7>
618 %xor = xor <4 x i32> %shuf1, %shuf2
622 define <4 x i32> @combine_nested_undef_test1(<4 x i32> %A, <4 x i32> %B) {
623 ; SSE-LABEL: combine_nested_undef_test1:
625 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,1,0,1]
628 ; AVX-LABEL: combine_nested_undef_test1:
630 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,1,0,1]
632 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 3, i32 1>
633 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3>
637 define <4 x i32> @combine_nested_undef_test2(<4 x i32> %A, <4 x i32> %B) {
638 ; SSE-LABEL: combine_nested_undef_test2:
640 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,1,0,3]
643 ; AVX-LABEL: combine_nested_undef_test2:
645 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,1,0,3]
647 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
648 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3>
652 define <4 x i32> @combine_nested_undef_test3(<4 x i32> %A, <4 x i32> %B) {
653 ; SSE-LABEL: combine_nested_undef_test3:
655 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,1,0,3]
658 ; AVX-LABEL: combine_nested_undef_test3:
660 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,1,0,3]
662 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
663 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 3>
667 define <4 x i32> @combine_nested_undef_test4(<4 x i32> %A, <4 x i32> %B) {
668 ; SSE-LABEL: combine_nested_undef_test4:
670 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
673 ; AVX1-LABEL: combine_nested_undef_test4:
675 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,0,1]
678 ; AVX2-LABEL: combine_nested_undef_test4:
680 ; AVX2-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
682 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 7, i32 1>
683 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 4, i32 4, i32 0, i32 3>
687 define <4 x i32> @combine_nested_undef_test5(<4 x i32> %A, <4 x i32> %B) {
688 ; SSE-LABEL: combine_nested_undef_test5:
690 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
693 ; AVX-LABEL: combine_nested_undef_test5:
695 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,3,2,3]
697 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 5, i32 5, i32 2, i32 3>
698 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 4, i32 3>
702 define <4 x i32> @combine_nested_undef_test6(<4 x i32> %A, <4 x i32> %B) {
703 ; SSE-LABEL: combine_nested_undef_test6:
705 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
708 ; AVX-LABEL: combine_nested_undef_test6:
710 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,3,0,1]
712 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 4>
713 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 4, i32 0, i32 4>
717 define <4 x i32> @combine_nested_undef_test7(<4 x i32> %A, <4 x i32> %B) {
718 ; SSE-LABEL: combine_nested_undef_test7:
720 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,0,2]
723 ; AVX-LABEL: combine_nested_undef_test7:
725 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,0,2]
727 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
728 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 0, i32 2>
732 define <4 x i32> @combine_nested_undef_test8(<4 x i32> %A, <4 x i32> %B) {
733 ; SSE-LABEL: combine_nested_undef_test8:
735 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
738 ; AVX-LABEL: combine_nested_undef_test8:
740 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,1,3,3]
742 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
743 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 4, i32 3, i32 4>
747 define <4 x i32> @combine_nested_undef_test9(<4 x i32> %A, <4 x i32> %B) {
748 ; SSE-LABEL: combine_nested_undef_test9:
750 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,3,2,2]
753 ; AVX-LABEL: combine_nested_undef_test9:
755 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,3,2,2]
757 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 3, i32 2, i32 5>
758 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
762 define <4 x i32> @combine_nested_undef_test10(<4 x i32> %A, <4 x i32> %B) {
763 ; SSE-LABEL: combine_nested_undef_test10:
765 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,1,3]
768 ; AVX-LABEL: combine_nested_undef_test10:
770 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,1,1,3]
772 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 1, i32 5, i32 5>
773 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 4>
777 define <4 x i32> @combine_nested_undef_test11(<4 x i32> %A, <4 x i32> %B) {
778 ; SSE-LABEL: combine_nested_undef_test11:
780 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,2,1]
783 ; AVX-LABEL: combine_nested_undef_test11:
785 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,1,2,1]
787 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 2, i32 5, i32 4>
788 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 0>
792 define <4 x i32> @combine_nested_undef_test12(<4 x i32> %A, <4 x i32> %B) {
793 ; SSE-LABEL: combine_nested_undef_test12:
795 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
798 ; AVX1-LABEL: combine_nested_undef_test12:
800 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,0,1]
803 ; AVX2-LABEL: combine_nested_undef_test12:
805 ; AVX2-NEXT: vbroadcastss %xmm0, %xmm0
807 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 0, i32 2, i32 4>
808 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 4, i32 0, i32 4>
812 ; The following pair of shuffles is folded into vector %A.
813 define <4 x i32> @combine_nested_undef_test13(<4 x i32> %A, <4 x i32> %B) {
814 ; CHECK-LABEL: combine_nested_undef_test13:
817 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 1, i32 4, i32 2, i32 6>
818 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 4, i32 0, i32 2, i32 4>
822 ; The following pair of shuffles is folded into vector %B.
823 define <4 x i32> @combine_nested_undef_test14(<4 x i32> %A, <4 x i32> %B) {
824 ; SSE-LABEL: combine_nested_undef_test14:
826 ; SSE-NEXT: movaps %xmm1, %xmm0
829 ; AVX-LABEL: combine_nested_undef_test14:
831 ; AVX-NEXT: vmovaps %xmm1, %xmm0
833 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 6, i32 2, i32 4>
834 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 4, i32 1, i32 4>
839 ; Verify that we don't optimize the following cases. We expect more than one shuffle.
841 ; FIXME: Many of these already don't make sense, and the rest should stop
842 ; making sense with th enew vector shuffle lowering. Revisit at least testing for
845 define <4 x i32> @combine_nested_undef_test15(<4 x i32> %A, <4 x i32> %B) {
846 ; SSE2-LABEL: combine_nested_undef_test15:
848 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[3,0]
849 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[0,1]
850 ; SSE2-NEXT: movaps %xmm1, %xmm0
853 ; SSSE3-LABEL: combine_nested_undef_test15:
855 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[3,0]
856 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[0,1]
857 ; SSSE3-NEXT: movaps %xmm1, %xmm0
860 ; SSE41-LABEL: combine_nested_undef_test15:
862 ; SSE41-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,0,1,1]
863 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,1,0,1]
864 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
867 ; AVX-LABEL: combine_nested_undef_test15:
869 ; AVX-NEXT: vpermilps {{.*#+}} xmm1 = xmm1[0,0,1,1]
870 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,1,0,1]
871 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
873 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 3, i32 1>
874 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3>
878 define <4 x i32> @combine_nested_undef_test16(<4 x i32> %A, <4 x i32> %B) {
879 ; SSE2-LABEL: combine_nested_undef_test16:
881 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]
882 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,2,3]
883 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
886 ; SSSE3-LABEL: combine_nested_undef_test16:
888 ; SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]
889 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,0,2,3]
890 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
893 ; SSE41-LABEL: combine_nested_undef_test16:
895 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
896 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7]
899 ; AVX-LABEL: combine_nested_undef_test16:
901 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,3,0,1]
902 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3]
904 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
905 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3>
909 define <4 x i32> @combine_nested_undef_test17(<4 x i32> %A, <4 x i32> %B) {
910 ; SSE2-LABEL: combine_nested_undef_test17:
912 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0]
913 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,1],xmm1[0,2]
916 ; SSSE3-LABEL: combine_nested_undef_test17:
918 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[1,0]
919 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,1],xmm1[0,2]
922 ; SSE41-LABEL: combine_nested_undef_test17:
924 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3,4,5,6,7]
925 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,1,0,1]
928 ; AVX-LABEL: combine_nested_undef_test17:
930 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
931 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,1,0,1]
933 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 3, i32 1>
934 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3>
938 define <4 x i32> @combine_nested_undef_test18(<4 x i32> %A, <4 x i32> %B) {
939 ; SSE-LABEL: combine_nested_undef_test18:
941 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,0,3]
944 ; AVX-LABEL: combine_nested_undef_test18:
946 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[1,1,0,3]
948 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
949 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 0, i32 3>
953 define <4 x i32> @combine_nested_undef_test19(<4 x i32> %A, <4 x i32> %B) {
954 ; SSE2-LABEL: combine_nested_undef_test19:
956 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
957 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,0,0,0]
960 ; SSSE3-LABEL: combine_nested_undef_test19:
962 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
963 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,0,0,0]
966 ; SSE41-LABEL: combine_nested_undef_test19:
968 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
969 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,0,0,0]
972 ; AVX-LABEL: combine_nested_undef_test19:
974 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2,3]
975 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[1,0,0,0]
977 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 0, i32 4, i32 5, i32 6>
978 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 0, i32 0, i32 0>
982 define <4 x i32> @combine_nested_undef_test20(<4 x i32> %A, <4 x i32> %B) {
983 ; SSE2-LABEL: combine_nested_undef_test20:
985 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[2,3]
986 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2,3,1]
987 ; SSE2-NEXT: movaps %xmm1, %xmm0
990 ; SSSE3-LABEL: combine_nested_undef_test20:
992 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[2,3]
993 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2,3,1]
994 ; SSSE3-NEXT: movaps %xmm1, %xmm0
997 ; SSE41-LABEL: combine_nested_undef_test20:
999 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5,6,7]
1000 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,3,0]
1003 ; AVX-LABEL: combine_nested_undef_test20:
1005 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
1006 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,3,0]
1008 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 3, i32 2, i32 4, i32 4>
1009 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 0, i32 3>
1013 define <4 x i32> @combine_nested_undef_test21(<4 x i32> %A, <4 x i32> %B) {
1014 ; SSE2-LABEL: combine_nested_undef_test21:
1016 ; SSE2-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
1017 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,3,0,3]
1020 ; SSSE3-LABEL: combine_nested_undef_test21:
1022 ; SSSE3-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
1023 ; SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,3,0,3]
1026 ; SSE41-LABEL: combine_nested_undef_test21:
1028 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5,6,7]
1029 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
1032 ; AVX1-LABEL: combine_nested_undef_test21:
1034 ; AVX1-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1035 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,0,1]
1038 ; AVX2-LABEL: combine_nested_undef_test21:
1040 ; AVX2-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1041 ; AVX2-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
1043 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 3, i32 1>
1044 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 3>
1049 ; Test that we correctly combine shuffles according to rule
1050 ; shuffle(shuffle(x, y), undef) -> shuffle(y, undef)
1052 define <4 x i32> @combine_nested_undef_test22(<4 x i32> %A, <4 x i32> %B) {
1053 ; SSE-LABEL: combine_nested_undef_test22:
1055 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,3]
1058 ; AVX-LABEL: combine_nested_undef_test22:
1060 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[1,1,1,3]
1062 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
1063 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 3>
1067 define <4 x i32> @combine_nested_undef_test23(<4 x i32> %A, <4 x i32> %B) {
1068 ; SSE-LABEL: combine_nested_undef_test23:
1070 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,1,0,3]
1073 ; AVX-LABEL: combine_nested_undef_test23:
1075 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[0,1,0,3]
1077 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 5, i32 2, i32 7>
1078 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 0, i32 3>
1082 define <4 x i32> @combine_nested_undef_test24(<4 x i32> %A, <4 x i32> %B) {
1083 ; SSE-LABEL: combine_nested_undef_test24:
1085 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[0,3,2,3]
1088 ; AVX-LABEL: combine_nested_undef_test24:
1090 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[0,3,2,3]
1092 %1 = shufflevector <4 x i32> %A, <4 x i32> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
1093 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 4>
1097 define <4 x i32> @combine_nested_undef_test25(<4 x i32> %A, <4 x i32> %B) {
1098 ; SSE-LABEL: combine_nested_undef_test25:
1100 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
1103 ; AVX1-LABEL: combine_nested_undef_test25:
1105 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,0,1]
1108 ; AVX2-LABEL: combine_nested_undef_test25:
1110 ; AVX2-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
1112 %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 5, i32 2, i32 4>
1113 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 1, i32 3, i32 1>
1117 define <4 x i32> @combine_nested_undef_test26(<4 x i32> %A, <4 x i32> %B) {
1118 ; SSE-LABEL: combine_nested_undef_test26:
1120 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
1123 ; AVX-LABEL: combine_nested_undef_test26:
1125 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,3,2,3]
1127 %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 2, i32 6, i32 7>
1128 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 2, i32 3>
1132 define <4 x i32> @combine_nested_undef_test27(<4 x i32> %A, <4 x i32> %B) {
1133 ; SSE-LABEL: combine_nested_undef_test27:
1135 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
1138 ; AVX1-LABEL: combine_nested_undef_test27:
1140 ; AVX1-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,0,1]
1143 ; AVX2-LABEL: combine_nested_undef_test27:
1145 ; AVX2-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
1147 %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 2, i32 1, i32 5, i32 4>
1148 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 3, i32 2>
1152 define <4 x i32> @combine_nested_undef_test28(<4 x i32> %A, <4 x i32> %B) {
1153 ; SSE-LABEL: combine_nested_undef_test28:
1155 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,1,0]
1158 ; AVX-LABEL: combine_nested_undef_test28:
1160 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,1,1,0]
1162 %1 = shufflevector <4 x i32> %B, <4 x i32> %A, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
1163 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 3, i32 2>
1167 define <4 x float> @combine_test1(<4 x float> %a, <4 x float> %b) {
1168 ; SSE-LABEL: combine_test1:
1170 ; SSE-NEXT: movaps %xmm1, %xmm0
1173 ; AVX-LABEL: combine_test1:
1175 ; AVX-NEXT: vmovaps %xmm1, %xmm0
1177 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1178 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1182 define <4 x float> @combine_test2(<4 x float> %a, <4 x float> %b) {
1183 ; SSE2-LABEL: combine_test2:
1185 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1186 ; SSE2-NEXT: movaps %xmm1, %xmm0
1189 ; SSSE3-LABEL: combine_test2:
1191 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1192 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1195 ; SSE41-LABEL: combine_test2:
1197 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1200 ; AVX-LABEL: combine_test2:
1202 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1204 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1205 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
1209 define <4 x float> @combine_test3(<4 x float> %a, <4 x float> %b) {
1210 ; SSE-LABEL: combine_test3:
1212 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1215 ; AVX-LABEL: combine_test3:
1217 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1219 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
1220 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
1224 define <4 x float> @combine_test4(<4 x float> %a, <4 x float> %b) {
1225 ; SSE-LABEL: combine_test4:
1227 ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1230 ; AVX-LABEL: combine_test4:
1232 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1234 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
1235 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
1239 define <4 x float> @combine_test5(<4 x float> %a, <4 x float> %b) {
1240 ; SSE2-LABEL: combine_test5:
1242 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1243 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1246 ; SSSE3-LABEL: combine_test5:
1248 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1249 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1252 ; SSE41-LABEL: combine_test5:
1254 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1257 ; AVX-LABEL: combine_test5:
1259 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1261 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1262 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
1266 define <4 x i32> @combine_test6(<4 x i32> %a, <4 x i32> %b) {
1267 ; SSE-LABEL: combine_test6:
1269 ; SSE-NEXT: movaps %xmm1, %xmm0
1272 ; AVX-LABEL: combine_test6:
1274 ; AVX-NEXT: vmovaps %xmm1, %xmm0
1276 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1277 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1281 define <4 x i32> @combine_test7(<4 x i32> %a, <4 x i32> %b) {
1282 ; SSE2-LABEL: combine_test7:
1284 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1285 ; SSE2-NEXT: movaps %xmm1, %xmm0
1288 ; SSSE3-LABEL: combine_test7:
1290 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1291 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1294 ; SSE41-LABEL: combine_test7:
1296 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1299 ; AVX-LABEL: combine_test7:
1301 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1303 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1304 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
1308 define <4 x i32> @combine_test8(<4 x i32> %a, <4 x i32> %b) {
1309 ; SSE-LABEL: combine_test8:
1311 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1314 ; AVX-LABEL: combine_test8:
1316 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1318 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
1319 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
1323 define <4 x i32> @combine_test9(<4 x i32> %a, <4 x i32> %b) {
1324 ; SSE-LABEL: combine_test9:
1326 ; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1],xmm0[1]
1327 ; SSE-NEXT: movaps %xmm1, %xmm0
1330 ; AVX-LABEL: combine_test9:
1332 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1334 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
1335 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
1339 define <4 x i32> @combine_test10(<4 x i32> %a, <4 x i32> %b) {
1340 ; SSE2-LABEL: combine_test10:
1342 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1343 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1346 ; SSSE3-LABEL: combine_test10:
1348 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1349 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1352 ; SSE41-LABEL: combine_test10:
1354 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1357 ; AVX-LABEL: combine_test10:
1359 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1361 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1362 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
1366 define <4 x float> @combine_test11(<4 x float> %a, <4 x float> %b) {
1367 ; CHECK-LABEL: combine_test11:
1370 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1371 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1375 define <4 x float> @combine_test12(<4 x float> %a, <4 x float> %b) {
1376 ; SSE2-LABEL: combine_test12:
1378 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1379 ; SSE2-NEXT: movaps %xmm1, %xmm0
1382 ; SSSE3-LABEL: combine_test12:
1384 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1385 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1388 ; SSE41-LABEL: combine_test12:
1390 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1393 ; AVX-LABEL: combine_test12:
1395 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1397 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
1398 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
1402 define <4 x float> @combine_test13(<4 x float> %a, <4 x float> %b) {
1403 ; SSE-LABEL: combine_test13:
1405 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1408 ; AVX-LABEL: combine_test13:
1410 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1412 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
1413 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
1417 define <4 x float> @combine_test14(<4 x float> %a, <4 x float> %b) {
1418 ; SSE-LABEL: combine_test14:
1420 ; SSE-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1423 ; AVX-LABEL: combine_test14:
1425 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1427 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 5, i32 5>
1428 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
1432 define <4 x float> @combine_test15(<4 x float> %a, <4 x float> %b) {
1433 ; SSE2-LABEL: combine_test15:
1435 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1436 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1439 ; SSSE3-LABEL: combine_test15:
1441 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1442 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1445 ; SSE41-LABEL: combine_test15:
1447 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1450 ; AVX-LABEL: combine_test15:
1452 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1454 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
1455 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
1459 define <4 x i32> @combine_test16(<4 x i32> %a, <4 x i32> %b) {
1460 ; CHECK-LABEL: combine_test16:
1463 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1464 %2 = shufflevector <4 x i32> %1, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1468 define <4 x i32> @combine_test17(<4 x i32> %a, <4 x i32> %b) {
1469 ; SSE2-LABEL: combine_test17:
1471 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1472 ; SSE2-NEXT: movaps %xmm1, %xmm0
1475 ; SSSE3-LABEL: combine_test17:
1477 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1478 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1481 ; SSE41-LABEL: combine_test17:
1483 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1486 ; AVX-LABEL: combine_test17:
1488 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1490 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
1491 %2 = shufflevector <4 x i32> %1, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
1495 define <4 x i32> @combine_test18(<4 x i32> %a, <4 x i32> %b) {
1496 ; SSE-LABEL: combine_test18:
1498 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1501 ; AVX-LABEL: combine_test18:
1503 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1505 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
1506 %2 = shufflevector <4 x i32> %1, <4 x i32> %a, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
1510 define <4 x i32> @combine_test19(<4 x i32> %a, <4 x i32> %b) {
1511 ; SSE-LABEL: combine_test19:
1513 ; SSE-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1516 ; AVX-LABEL: combine_test19:
1518 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1520 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 6, i32 7, i32 5, i32 5>
1521 %2 = shufflevector <4 x i32> %1, <4 x i32> %a, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
1525 define <4 x i32> @combine_test20(<4 x i32> %a, <4 x i32> %b) {
1526 ; SSE2-LABEL: combine_test20:
1528 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1529 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1532 ; SSSE3-LABEL: combine_test20:
1534 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm1[0,0]
1535 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[2,0],xmm1[2,3]
1538 ; SSE41-LABEL: combine_test20:
1540 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1543 ; AVX-LABEL: combine_test20:
1545 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
1547 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 7>
1548 %2 = shufflevector <4 x i32> %1, <4 x i32> %a, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
1552 define <4 x i32> @combine_test21(<8 x i32> %a, <4 x i32>* %ptr) {
1553 ; SSE-LABEL: combine_test21:
1555 ; SSE-NEXT: movaps %xmm0, %xmm2
1556 ; SSE-NEXT: movlhps {{.*#+}} xmm2 = xmm2[0],xmm1[0]
1557 ; SSE-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1558 ; SSE-NEXT: movaps %xmm2, (%rdi)
1561 ; AVX-LABEL: combine_test21:
1563 ; AVX-NEXT: vextractf128 $1, %ymm0, %xmm1
1564 ; AVX-NEXT: vmovlhps {{.*#+}} xmm2 = xmm0[0],xmm1[0]
1565 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
1566 ; AVX-NEXT: vmovaps %xmm2, (%rdi)
1567 ; AVX-NEXT: vzeroupper
1569 %1 = shufflevector <8 x i32> %a, <8 x i32> %a, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
1570 %2 = shufflevector <8 x i32> %a, <8 x i32> %a, <4 x i32> <i32 2, i32 3, i32 6, i32 7>
1571 store <4 x i32> %1, <4 x i32>* %ptr, align 16
1575 define <8 x float> @combine_test22(<2 x float>* %a, <2 x float>* %b) {
1576 ; SSE-LABEL: combine_test22:
1578 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
1579 ; SSE-NEXT: movhps {{.*#+}} xmm0 = xmm0[0,1],mem[0,1]
1582 ; AVX-LABEL: combine_test22:
1584 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
1585 ; AVX-NEXT: vmovhps {{.*#+}} xmm0 = xmm0[0,1],mem[0,1]
1587 ; Current AVX2 lowering of this is still awful, not adding a test case.
1588 %1 = load <2 x float>, <2 x float>* %a, align 8
1589 %2 = load <2 x float>, <2 x float>* %b, align 8
1590 %3 = shufflevector <2 x float> %1, <2 x float> %2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
1595 define void @combine_test23(<8 x float> %v, <2 x float>* %ptr) {
1596 ; SSE-LABEL: combine_test23:
1598 ; SSE-NEXT: movups %xmm0, (%rdi)
1601 ; AVX-LABEL: combine_test23:
1603 ; AVX-NEXT: vmovups %xmm0, (%rdi)
1604 ; AVX-NEXT: vzeroupper
1606 %idx2 = getelementptr inbounds <2 x float>, <2 x float>* %ptr, i64 1
1607 %shuffle0 = shufflevector <8 x float> %v, <8 x float> undef, <2 x i32> <i32 0, i32 1>
1608 %shuffle1 = shufflevector <8 x float> %v, <8 x float> undef, <2 x i32> <i32 2, i32 3>
1609 store <2 x float> %shuffle0, <2 x float>* %ptr, align 8
1610 store <2 x float> %shuffle1, <2 x float>* %idx2, align 8
1614 ; Check some negative cases.
1615 ; FIXME: Do any of these really make sense? Are they redundant with the above tests?
1617 define <4 x float> @combine_test1b(<4 x float> %a, <4 x float> %b) {
1618 ; SSE-LABEL: combine_test1b:
1620 ; SSE-NEXT: movaps %xmm1, %xmm0
1621 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,0]
1624 ; AVX-LABEL: combine_test1b:
1626 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[0,1,2,0]
1628 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1629 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 0>
1633 define <4 x float> @combine_test2b(<4 x float> %a, <4 x float> %b) {
1634 ; SSE2-LABEL: combine_test2b:
1636 ; SSE2-NEXT: movaps %xmm1, %xmm0
1637 ; SSE2-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
1640 ; SSSE3-LABEL: combine_test2b:
1642 ; SSSE3-NEXT: movddup {{.*#+}} xmm0 = xmm1[0,0]
1645 ; SSE41-LABEL: combine_test2b:
1647 ; SSE41-NEXT: movddup {{.*#+}} xmm0 = xmm1[0,0]
1650 ; AVX-LABEL: combine_test2b:
1652 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm1[0,0]
1654 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1655 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 0, i32 5>
1659 define <4 x float> @combine_test3b(<4 x float> %a, <4 x float> %b) {
1660 ; SSE2-LABEL: combine_test3b:
1662 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0],xmm1[3,0]
1663 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[2,3]
1666 ; SSSE3-LABEL: combine_test3b:
1668 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0],xmm1[3,0]
1669 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[2,3]
1672 ; SSE41-LABEL: combine_test3b:
1674 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
1675 ; SSE41-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,3,2,3]
1678 ; AVX-LABEL: combine_test3b:
1680 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
1681 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,3,2,3]
1683 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 6, i32 3>
1684 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 7, i32 2, i32 7>
1688 define <4 x float> @combine_test4b(<4 x float> %a, <4 x float> %b) {
1689 ; SSE-LABEL: combine_test4b:
1691 ; SSE-NEXT: movaps %xmm1, %xmm0
1692 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,1],xmm1[2,3]
1695 ; AVX-LABEL: combine_test4b:
1697 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm1[1,1,2,3]
1699 %1 = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1700 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 5, i32 5, i32 2, i32 7>
1705 ; Verify that we correctly fold shuffles even when we use illegal vector types.
1707 define <4 x i8> @combine_test1c(<4 x i8>* %a, <4 x i8>* %b) {
1708 ; SSE2-LABEL: combine_test1c:
1710 ; SSE2-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
1711 ; SSE2-NEXT: movss {{.*#+}} xmm2 = mem[0],zero,zero,zero
1712 ; SSE2-NEXT: movaps {{.*#+}} xmm0 = [0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
1713 ; SSE2-NEXT: andps %xmm0, %xmm2
1714 ; SSE2-NEXT: andnps %xmm1, %xmm0
1715 ; SSE2-NEXT: orps %xmm2, %xmm0
1718 ; SSSE3-LABEL: combine_test1c:
1720 ; SSSE3-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1721 ; SSSE3-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1722 ; SSSE3-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
1723 ; SSSE3-NEXT: pshufb {{.*#+}} xmm0 = xmm0[1,2,4,6,u,u,u,u,u,u,u,u,u,u,u,u]
1726 ; SSE41-LABEL: combine_test1c:
1728 ; SSE41-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1729 ; SSE41-NEXT: movd {{.*#+}} xmm2 = mem[0],zero,zero,zero
1730 ; SSE41-NEXT: movaps {{.*#+}} xmm0 = <0,255,255,255,u,u,u,u,u,u,u,u,u,u,u,u>
1731 ; SSE41-NEXT: pblendvb %xmm0, %xmm2, %xmm1
1732 ; SSE41-NEXT: movdqa %xmm1, %xmm0
1735 ; AVX-LABEL: combine_test1c:
1737 ; AVX-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1738 ; AVX-NEXT: vmovd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1739 ; AVX-NEXT: vmovdqa {{.*#+}} xmm2 = <0,255,255,255,u,u,u,u,u,u,u,u,u,u,u,u>
1740 ; AVX-NEXT: vpblendvb %xmm2, %xmm1, %xmm0, %xmm0
1742 %A = load <4 x i8>, <4 x i8>* %a
1743 %B = load <4 x i8>, <4 x i8>* %b
1744 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1745 %2 = shufflevector <4 x i8> %1, <4 x i8> %B, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
1749 define <4 x i8> @combine_test2c(<4 x i8>* %a, <4 x i8>* %b) {
1750 ; SSE-LABEL: combine_test2c:
1752 ; SSE-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1753 ; SSE-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1754 ; SSE-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
1757 ; AVX-LABEL: combine_test2c:
1759 ; AVX-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1760 ; AVX-NEXT: vmovd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1761 ; AVX-NEXT: vpunpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
1763 %A = load <4 x i8>, <4 x i8>* %a
1764 %B = load <4 x i8>, <4 x i8>* %b
1765 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 0, i32 5, i32 1, i32 5>
1766 %2 = shufflevector <4 x i8> %1, <4 x i8> %B, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
1770 define <4 x i8> @combine_test3c(<4 x i8>* %a, <4 x i8>* %b) {
1771 ; SSE-LABEL: combine_test3c:
1773 ; SSE-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1774 ; SSE-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1775 ; SSE-NEXT: punpcklwd {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
1776 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,2,3]
1779 ; AVX-LABEL: combine_test3c:
1781 ; AVX-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1782 ; AVX-NEXT: vmovd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1783 ; AVX-NEXT: vpunpcklwd {{.*#+}} xmm0 = xmm1[0],xmm0[0],xmm1[1],xmm0[1],xmm1[2],xmm0[2],xmm1[3],xmm0[3]
1784 ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,2,3]
1786 %A = load <4 x i8>, <4 x i8>* %a
1787 %B = load <4 x i8>, <4 x i8>* %b
1788 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
1789 %2 = shufflevector <4 x i8> %1, <4 x i8> %B, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
1793 define <4 x i8> @combine_test4c(<4 x i8>* %a, <4 x i8>* %b) {
1794 ; SSE2-LABEL: combine_test4c:
1796 ; SSE2-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
1797 ; SSE2-NEXT: movss {{.*#+}} xmm2 = mem[0],zero,zero,zero
1798 ; SSE2-NEXT: movaps {{.*#+}} xmm0 = [255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255]
1799 ; SSE2-NEXT: andps %xmm0, %xmm2
1800 ; SSE2-NEXT: andnps %xmm1, %xmm0
1801 ; SSE2-NEXT: orps %xmm2, %xmm0
1804 ; SSSE3-LABEL: combine_test4c:
1806 ; SSSE3-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1807 ; SSSE3-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1808 ; SSSE3-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
1809 ; SSSE3-NEXT: pshufb {{.*#+}} xmm0 = xmm0[0,3,4,6,u,u,u,u,u,u,u,u,u,u,u,u]
1812 ; SSE41-LABEL: combine_test4c:
1814 ; SSE41-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1815 ; SSE41-NEXT: movd {{.*#+}} xmm2 = mem[0],zero,zero,zero
1816 ; SSE41-NEXT: movaps {{.*#+}} xmm0 = <255,0,255,255,u,u,u,u,u,u,u,u,u,u,u,u>
1817 ; SSE41-NEXT: pblendvb %xmm0, %xmm2, %xmm1
1818 ; SSE41-NEXT: movdqa %xmm1, %xmm0
1821 ; AVX-LABEL: combine_test4c:
1823 ; AVX-NEXT: vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero
1824 ; AVX-NEXT: vmovd {{.*#+}} xmm1 = mem[0],zero,zero,zero
1825 ; AVX-NEXT: vmovdqa {{.*#+}} xmm2 = <255,0,255,255,u,u,u,u,u,u,u,u,u,u,u,u>
1826 ; AVX-NEXT: vpblendvb %xmm2, %xmm1, %xmm0, %xmm0
1828 %A = load <4 x i8>, <4 x i8>* %a
1829 %B = load <4 x i8>, <4 x i8>* %b
1830 %1 = shufflevector <4 x i8> %A, <4 x i8> %B, <4 x i32> <i32 4, i32 1, i32 6, i32 3>
1831 %2 = shufflevector <4 x i8> %1, <4 x i8> %B, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
1836 ; The following test cases are generated from this C++ code
1838 ;__m128 blend_01(__m128 a, __m128 b)
1841 ; s = _mm_blend_ps( s, b, 1<<0 );
1842 ; s = _mm_blend_ps( s, b, 1<<1 );
1846 ;__m128 blend_02(__m128 a, __m128 b)
1849 ; s = _mm_blend_ps( s, b, 1<<0 );
1850 ; s = _mm_blend_ps( s, b, 1<<2 );
1854 ;__m128 blend_123(__m128 a, __m128 b)
1857 ; s = _mm_blend_ps( s, b, 1<<1 );
1858 ; s = _mm_blend_ps( s, b, 1<<2 );
1859 ; s = _mm_blend_ps( s, b, 1<<3 );
1863 ; Ideally, we should collapse the following shuffles into a single one.
1865 define <4 x float> @combine_blend_01(<4 x float> %a, <4 x float> %b) {
1866 ; SSE2-LABEL: combine_blend_01:
1868 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
1871 ; SSSE3-LABEL: combine_blend_01:
1873 ; SSSE3-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
1876 ; SSE41-LABEL: combine_blend_01:
1878 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
1881 ; AVX-LABEL: combine_blend_01:
1883 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
1885 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 undef, i32 2, i32 3>
1886 %shuffle6 = shufflevector <4 x float> %shuffle, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
1887 ret <4 x float> %shuffle6
1890 define <4 x float> @combine_blend_02(<4 x float> %a, <4 x float> %b) {
1891 ; SSE2-LABEL: combine_blend_02:
1893 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[1,3]
1894 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2,1,3]
1895 ; SSE2-NEXT: movaps %xmm1, %xmm0
1898 ; SSSE3-LABEL: combine_blend_02:
1900 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[1,3]
1901 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2,1,3]
1902 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1905 ; SSE41-LABEL: combine_blend_02:
1907 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
1910 ; AVX-LABEL: combine_blend_02:
1912 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2],xmm0[3]
1914 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 undef, i32 3>
1915 %shuffle6 = shufflevector <4 x float> %shuffle, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 6, i32 3>
1916 ret <4 x float> %shuffle6
1919 define <4 x float> @combine_blend_123(<4 x float> %a, <4 x float> %b) {
1920 ; SSE2-LABEL: combine_blend_123:
1922 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1923 ; SSE2-NEXT: movaps %xmm1, %xmm0
1926 ; SSSE3-LABEL: combine_blend_123:
1928 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
1929 ; SSSE3-NEXT: movaps %xmm1, %xmm0
1932 ; SSE41-LABEL: combine_blend_123:
1934 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1937 ; AVX-LABEL: combine_blend_123:
1939 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
1941 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef>
1942 %shuffle6 = shufflevector <4 x float> %shuffle, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 6, i32 undef>
1943 %shuffle12 = shufflevector <4 x float> %shuffle6, <4 x float> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
1944 ret <4 x float> %shuffle12
1947 define <4 x i32> @combine_test_movhl_1(<4 x i32> %a, <4 x i32> %b) {
1948 ; SSE-LABEL: combine_test_movhl_1:
1950 ; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1],xmm0[1]
1951 ; SSE-NEXT: movaps %xmm1, %xmm0
1954 ; AVX-LABEL: combine_test_movhl_1:
1956 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1958 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 7, i32 5, i32 3>
1959 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 6, i32 1, i32 0, i32 3>
1963 define <4 x i32> @combine_test_movhl_2(<4 x i32> %a, <4 x i32> %b) {
1964 ; SSE-LABEL: combine_test_movhl_2:
1966 ; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1],xmm0[1]
1967 ; SSE-NEXT: movaps %xmm1, %xmm0
1970 ; AVX-LABEL: combine_test_movhl_2:
1972 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1974 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 0, i32 3, i32 6>
1975 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 3, i32 7, i32 0, i32 2>
1979 define <4 x i32> @combine_test_movhl_3(<4 x i32> %a, <4 x i32> %b) {
1980 ; SSE-LABEL: combine_test_movhl_3:
1982 ; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1],xmm0[1]
1983 ; SSE-NEXT: movaps %xmm1, %xmm0
1986 ; AVX-LABEL: combine_test_movhl_3:
1988 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
1990 %1 = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 7, i32 6, i32 3, i32 2>
1991 %2 = shufflevector <4 x i32> %1, <4 x i32> %b, <4 x i32> <i32 6, i32 0, i32 3, i32 2>
1996 ; Verify that we fold shuffles according to rule:
1997 ; (shuffle(shuffle A, Undef, M0), B, M1) -> (shuffle A, B, M2)
1999 define <4 x float> @combine_undef_input_test1(<4 x float> %a, <4 x float> %b) {
2000 ; SSE2-LABEL: combine_undef_input_test1:
2002 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
2005 ; SSSE3-LABEL: combine_undef_input_test1:
2007 ; SSSE3-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
2010 ; SSE41-LABEL: combine_undef_input_test1:
2012 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
2015 ; AVX-LABEL: combine_undef_input_test1:
2017 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
2019 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
2020 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
2024 define <4 x float> @combine_undef_input_test2(<4 x float> %a, <4 x float> %b) {
2025 ; SSE-LABEL: combine_undef_input_test2:
2027 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2030 ; AVX-LABEL: combine_undef_input_test2:
2032 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2034 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
2035 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
2039 define <4 x float> @combine_undef_input_test3(<4 x float> %a, <4 x float> %b) {
2040 ; SSE-LABEL: combine_undef_input_test3:
2042 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2045 ; AVX-LABEL: combine_undef_input_test3:
2047 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2049 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
2050 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
2054 define <4 x float> @combine_undef_input_test4(<4 x float> %a, <4 x float> %b) {
2055 ; SSE-LABEL: combine_undef_input_test4:
2057 ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm1[1],xmm0[1]
2060 ; AVX-LABEL: combine_undef_input_test4:
2062 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
2064 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
2065 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
2069 define <4 x float> @combine_undef_input_test5(<4 x float> %a, <4 x float> %b) {
2070 ; SSE2-LABEL: combine_undef_input_test5:
2072 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2075 ; SSSE3-LABEL: combine_undef_input_test5:
2077 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2080 ; SSE41-LABEL: combine_undef_input_test5:
2082 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2085 ; AVX-LABEL: combine_undef_input_test5:
2087 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2089 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
2090 %2 = shufflevector <4 x float> %1, <4 x float> %b, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
2095 ; Verify that we fold shuffles according to rule:
2096 ; (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
2098 define <4 x float> @combine_undef_input_test6(<4 x float> %a) {
2099 ; CHECK-LABEL: combine_undef_input_test6:
2102 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
2103 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 4, i32 5, i32 1, i32 2>
2107 define <4 x float> @combine_undef_input_test7(<4 x float> %a) {
2108 ; SSE2-LABEL: combine_undef_input_test7:
2110 ; SSE2-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0,0]
2113 ; SSSE3-LABEL: combine_undef_input_test7:
2115 ; SSSE3-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2118 ; SSE41-LABEL: combine_undef_input_test7:
2120 ; SSE41-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2123 ; AVX-LABEL: combine_undef_input_test7:
2125 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
2127 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
2128 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 1, i32 2, i32 4, i32 5>
2132 define <4 x float> @combine_undef_input_test8(<4 x float> %a) {
2133 ; SSE2-LABEL: combine_undef_input_test8:
2135 ; SSE2-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0,0]
2138 ; SSSE3-LABEL: combine_undef_input_test8:
2140 ; SSSE3-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2143 ; SSE41-LABEL: combine_undef_input_test8:
2145 ; SSE41-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2148 ; AVX-LABEL: combine_undef_input_test8:
2150 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
2152 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
2153 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 4, i32 1>
2157 define <4 x float> @combine_undef_input_test9(<4 x float> %a) {
2158 ; SSE-LABEL: combine_undef_input_test9:
2160 ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1]
2163 ; AVX-LABEL: combine_undef_input_test9:
2165 ; AVX-NEXT: vpermilpd {{.*#+}} xmm0 = xmm0[1,1]
2167 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
2168 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
2172 define <4 x float> @combine_undef_input_test10(<4 x float> %a) {
2173 ; CHECK-LABEL: combine_undef_input_test10:
2176 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
2177 %2 = shufflevector <4 x float> %1, <4 x float> %a, <4 x i32> <i32 0, i32 2, i32 6, i32 7>
2181 define <4 x float> @combine_undef_input_test11(<4 x float> %a, <4 x float> %b) {
2182 ; SSE2-LABEL: combine_undef_input_test11:
2184 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
2187 ; SSSE3-LABEL: combine_undef_input_test11:
2189 ; SSSE3-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
2192 ; SSE41-LABEL: combine_undef_input_test11:
2194 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
2197 ; AVX-LABEL: combine_undef_input_test11:
2199 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3]
2201 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
2202 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 5, i32 6>
2206 define <4 x float> @combine_undef_input_test12(<4 x float> %a, <4 x float> %b) {
2207 ; SSE-LABEL: combine_undef_input_test12:
2209 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2212 ; AVX-LABEL: combine_undef_input_test12:
2214 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2216 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
2217 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 5, i32 6, i32 0, i32 1>
2221 define <4 x float> @combine_undef_input_test13(<4 x float> %a, <4 x float> %b) {
2222 ; SSE-LABEL: combine_undef_input_test13:
2224 ; SSE-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2227 ; AVX-LABEL: combine_undef_input_test13:
2229 ; AVX-NEXT: vmovlhps {{.*#+}} xmm0 = xmm0[0],xmm1[0]
2231 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
2232 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 5, i32 0, i32 5>
2236 define <4 x float> @combine_undef_input_test14(<4 x float> %a, <4 x float> %b) {
2237 ; SSE-LABEL: combine_undef_input_test14:
2239 ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm1[1],xmm0[1]
2242 ; AVX-LABEL: combine_undef_input_test14:
2244 ; AVX-NEXT: vunpckhpd {{.*#+}} xmm0 = xmm1[1],xmm0[1]
2246 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
2247 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
2251 define <4 x float> @combine_undef_input_test15(<4 x float> %a, <4 x float> %b) {
2252 ; SSE2-LABEL: combine_undef_input_test15:
2254 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2257 ; SSSE3-LABEL: combine_undef_input_test15:
2259 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2262 ; SSE41-LABEL: combine_undef_input_test15:
2264 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2267 ; AVX-LABEL: combine_undef_input_test15:
2269 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3]
2271 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
2272 %2 = shufflevector <4 x float> %b, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 2, i32 3>
2277 ; Verify that shuffles are canonicalized according to rules:
2278 ; shuffle(B, shuffle(A, Undef)) -> shuffle(shuffle(A, Undef), B)
2280 ; This allows to trigger the following combine rule:
2281 ; (shuffle(shuffle A, Undef, M0), A, M1) -> (shuffle A, Undef, M2)
2283 ; As a result, all the shuffle pairs in each function below should be
2284 ; combined into a single legal shuffle operation.
2286 define <4 x float> @combine_undef_input_test16(<4 x float> %a) {
2287 ; CHECK-LABEL: combine_undef_input_test16:
2290 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 4, i32 2, i32 3, i32 1>
2291 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 0, i32 1, i32 5, i32 3>
2295 define <4 x float> @combine_undef_input_test17(<4 x float> %a) {
2296 ; SSE2-LABEL: combine_undef_input_test17:
2298 ; SSE2-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0,0]
2301 ; SSSE3-LABEL: combine_undef_input_test17:
2303 ; SSSE3-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2306 ; SSE41-LABEL: combine_undef_input_test17:
2308 ; SSE41-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2311 ; AVX-LABEL: combine_undef_input_test17:
2313 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
2315 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 6, i32 0, i32 1, i32 7>
2316 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 5, i32 6, i32 0, i32 1>
2320 define <4 x float> @combine_undef_input_test18(<4 x float> %a) {
2321 ; SSE2-LABEL: combine_undef_input_test18:
2323 ; SSE2-NEXT: movlhps {{.*#+}} xmm0 = xmm0[0,0]
2326 ; SSSE3-LABEL: combine_undef_input_test18:
2328 ; SSSE3-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2331 ; SSE41-LABEL: combine_undef_input_test18:
2333 ; SSE41-NEXT: movddup {{.*#+}} xmm0 = xmm0[0,0]
2336 ; AVX-LABEL: combine_undef_input_test18:
2338 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
2340 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
2341 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 0, i32 5>
2345 define <4 x float> @combine_undef_input_test19(<4 x float> %a) {
2346 ; SSE-LABEL: combine_undef_input_test19:
2348 ; SSE-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1]
2351 ; AVX-LABEL: combine_undef_input_test19:
2353 ; AVX-NEXT: vpermilpd {{.*#+}} xmm0 = xmm0[1,1]
2355 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 5, i32 5>
2356 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
2360 define <4 x float> @combine_undef_input_test20(<4 x float> %a) {
2361 ; CHECK-LABEL: combine_undef_input_test20:
2364 %1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 4, i32 1, i32 3>
2365 %2 = shufflevector <4 x float> %a, <4 x float> %1, <4 x i32> <i32 4, i32 6, i32 2, i32 3>
2369 ; These tests are designed to test the ability to combine away unnecessary
2370 ; operations feeding into a shuffle. The AVX cases are the important ones as
2371 ; they leverage operations which cannot be done naturally on the entire vector
2372 ; and thus are decomposed into multiple smaller operations.
2374 define <8 x i32> @combine_unneeded_subvector1(<8 x i32> %a) {
2375 ; SSE-LABEL: combine_unneeded_subvector1:
2377 ; SSE-NEXT: paddd {{.*}}(%rip), %xmm1
2378 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm1[3,2,1,0]
2379 ; SSE-NEXT: movdqa %xmm0, %xmm1
2382 ; AVX1-LABEL: combine_unneeded_subvector1:
2384 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
2385 ; AVX1-NEXT: vpaddd {{.*}}(%rip), %xmm0, %xmm0
2386 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
2387 ; AVX1-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
2388 ; AVX1-NEXT: vperm2f128 {{.*#+}} ymm0 = ymm0[2,3,2,3]
2391 ; AVX2-SLOW-LABEL: combine_unneeded_subvector1:
2392 ; AVX2-SLOW: # %bb.0:
2393 ; AVX2-SLOW-NEXT: vpaddd {{.*}}(%rip), %ymm0, %ymm0
2394 ; AVX2-SLOW-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
2395 ; AVX2-SLOW-NEXT: vpermq {{.*#+}} ymm0 = ymm0[2,3,2,3]
2396 ; AVX2-SLOW-NEXT: retq
2398 ; AVX2-FAST-LABEL: combine_unneeded_subvector1:
2399 ; AVX2-FAST: # %bb.0:
2400 ; AVX2-FAST-NEXT: vpaddd {{.*}}(%rip), %ymm0, %ymm0
2401 ; AVX2-FAST-NEXT: vbroadcasti128 {{.*#+}} ymm1 = [7,6,5,4,7,6,5,4]
2402 ; AVX2-FAST-NEXT: # ymm1 = mem[0,1,0,1]
2403 ; AVX2-FAST-NEXT: vpermd %ymm0, %ymm1, %ymm0
2404 ; AVX2-FAST-NEXT: retq
2405 %b = add <8 x i32> %a, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
2406 %c = shufflevector <8 x i32> %b, <8 x i32> undef, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 7, i32 6, i32 5, i32 4>
2410 define <8 x i32> @combine_unneeded_subvector2(<8 x i32> %a, <8 x i32> %b) {
2411 ; SSE-LABEL: combine_unneeded_subvector2:
2413 ; SSE-NEXT: paddd {{.*}}(%rip), %xmm1
2414 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm3[3,2,1,0]
2415 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[3,2,1,0]
2418 ; AVX1-LABEL: combine_unneeded_subvector2:
2420 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
2421 ; AVX1-NEXT: vpaddd {{.*}}(%rip), %xmm0, %xmm0
2422 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
2423 ; AVX1-NEXT: vperm2f128 {{.*#+}} ymm0 = ymm1[2,3],ymm0[2,3]
2424 ; AVX1-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
2427 ; AVX2-LABEL: combine_unneeded_subvector2:
2429 ; AVX2-NEXT: vpaddd {{.*}}(%rip), %ymm0, %ymm0
2430 ; AVX2-NEXT: vperm2i128 {{.*#+}} ymm0 = ymm1[2,3],ymm0[2,3]
2431 ; AVX2-NEXT: vpshufd {{.*#+}} ymm0 = ymm0[3,2,1,0,7,6,5,4]
2433 %c = add <8 x i32> %a, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
2434 %d = shufflevector <8 x i32> %b, <8 x i32> %c, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 15, i32 14, i32 13, i32 12>
2438 define <4 x float> @combine_insertps1(<4 x float> %a, <4 x float> %b) {
2439 ; SSE2-LABEL: combine_insertps1:
2441 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[1,0]
2442 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[2,3]
2443 ; SSE2-NEXT: movaps %xmm1, %xmm0
2446 ; SSSE3-LABEL: combine_insertps1:
2448 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[1,0]
2449 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,2],xmm0[2,3]
2450 ; SSSE3-NEXT: movaps %xmm1, %xmm0
2453 ; SSE41-LABEL: combine_insertps1:
2455 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = xmm1[2],xmm0[1,2,3]
2458 ; AVX-LABEL: combine_insertps1:
2460 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm1[2],xmm0[1,2,3]
2463 %c = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32><i32 0, i32 6, i32 2, i32 4>
2464 %d = shufflevector <4 x float> %a, <4 x float> %c, <4 x i32> <i32 5, i32 1, i32 6, i32 3>
2468 define <4 x float> @combine_insertps2(<4 x float> %a, <4 x float> %b) {
2469 ; SSE2-LABEL: combine_insertps2:
2471 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[0,0]
2472 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[2,3]
2473 ; SSE2-NEXT: movaps %xmm1, %xmm0
2476 ; SSSE3-LABEL: combine_insertps2:
2478 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[0,0]
2479 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],xmm0[2,3]
2480 ; SSSE3-NEXT: movaps %xmm1, %xmm0
2483 ; SSE41-LABEL: combine_insertps2:
2485 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = xmm0[0],xmm1[2],xmm0[2,3]
2488 ; AVX-LABEL: combine_insertps2:
2490 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],xmm1[2],xmm0[2,3]
2493 %c = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32><i32 0, i32 1, i32 6, i32 7>
2494 %d = shufflevector <4 x float> %a, <4 x float> %c, <4 x i32> <i32 4, i32 6, i32 2, i32 3>
2498 define <4 x float> @combine_insertps3(<4 x float> %a, <4 x float> %b) {
2499 ; SSE2-LABEL: combine_insertps3:
2501 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[3,0]
2502 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,2]
2505 ; SSSE3-LABEL: combine_insertps3:
2507 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[3,0]
2508 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,2]
2511 ; SSE41-LABEL: combine_insertps3:
2513 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0],xmm0[3]
2516 ; AVX-LABEL: combine_insertps3:
2518 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0,1],xmm1[0],xmm0[3]
2521 %c = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32><i32 0, i32 4, i32 2, i32 5>
2522 %d = shufflevector <4 x float> %a, <4 x float> %c, <4 x i32><i32 4, i32 1, i32 5, i32 3>
2526 define <4 x float> @combine_insertps4(<4 x float> %a, <4 x float> %b) {
2527 ; SSE2-LABEL: combine_insertps4:
2529 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[2,0]
2530 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,0]
2533 ; SSSE3-LABEL: combine_insertps4:
2535 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0],xmm0[2,0]
2536 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,0]
2539 ; SSE41-LABEL: combine_insertps4:
2541 ; SSE41-NEXT: insertps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[0]
2544 ; AVX-LABEL: combine_insertps4:
2546 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[0]
2549 %c = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32><i32 0, i32 4, i32 2, i32 5>
2550 %d = shufflevector <4 x float> %a, <4 x float> %c, <4 x i32><i32 4, i32 1, i32 6, i32 5>
2554 define void @combine_scalar_load_with_blend_with_zero(double* %a0, <4 x float>* %a1) {
2555 ; SSE-LABEL: combine_scalar_load_with_blend_with_zero:
2557 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
2558 ; SSE-NEXT: movaps %xmm0, (%rsi)
2561 ; AVX-LABEL: combine_scalar_load_with_blend_with_zero:
2563 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
2564 ; AVX-NEXT: vmovaps %xmm0, (%rsi)
2566 %1 = load double, double* %a0, align 8
2567 %2 = insertelement <2 x double> undef, double %1, i32 0
2568 %3 = insertelement <2 x double> %2, double 0.000000e+00, i32 1
2569 %4 = bitcast <2 x double> %3 to <4 x float>
2570 %5 = shufflevector <4 x float> %4, <4 x float> <float 0.000000e+00, float undef, float undef, float undef>, <4 x i32> <i32 0, i32 1, i32 4, i32 3>
2571 store <4 x float> %5, <4 x float>* %a1, align 16
2576 define <4 x float> @combine_constant_insertion_v4f32(float %f) {
2577 ; SSE2-LABEL: combine_constant_insertion_v4f32:
2579 ; SSE2-NEXT: movaps {{.*#+}} xmm1 = <u,4.0E+0,5.0E+0,3.0E+0>
2580 ; SSE2-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
2581 ; SSE2-NEXT: movaps %xmm1, %xmm0
2584 ; SSSE3-LABEL: combine_constant_insertion_v4f32:
2586 ; SSSE3-NEXT: movaps {{.*#+}} xmm1 = <u,4.0E+0,5.0E+0,3.0E+0>
2587 ; SSSE3-NEXT: movss {{.*#+}} xmm1 = xmm0[0],xmm1[1,2,3]
2588 ; SSSE3-NEXT: movaps %xmm1, %xmm0
2591 ; SSE41-LABEL: combine_constant_insertion_v4f32:
2593 ; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm0[0],mem[1,2,3]
2596 ; AVX-LABEL: combine_constant_insertion_v4f32:
2598 ; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],mem[1,2,3]
2600 %a0 = insertelement <4 x float> undef, float %f, i32 0
2601 %ret = shufflevector <4 x float> %a0, <4 x float> <float undef, float 4.0, float 5.0, float 3.0>, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
2602 ret <4 x float> %ret
2605 define <4 x i32> @combine_constant_insertion_v4i32(i32 %f) {
2606 ; SSE2-LABEL: combine_constant_insertion_v4i32:
2608 ; SSE2-NEXT: movd %edi, %xmm1
2609 ; SSE2-NEXT: movaps {{.*#+}} xmm0 = <u,4,5,30>
2610 ; SSE2-NEXT: movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
2613 ; SSSE3-LABEL: combine_constant_insertion_v4i32:
2615 ; SSSE3-NEXT: movd %edi, %xmm1
2616 ; SSSE3-NEXT: movaps {{.*#+}} xmm0 = <u,4,5,30>
2617 ; SSSE3-NEXT: movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
2620 ; SSE41-LABEL: combine_constant_insertion_v4i32:
2622 ; SSE41-NEXT: movdqa {{.*#+}} xmm0 = <u,4,5,30>
2623 ; SSE41-NEXT: pinsrd $0, %edi, %xmm0
2626 ; AVX-LABEL: combine_constant_insertion_v4i32:
2628 ; AVX-NEXT: vmovdqa {{.*#+}} xmm0 = <u,4,5,30>
2629 ; AVX-NEXT: vpinsrd $0, %edi, %xmm0, %xmm0
2631 %a0 = insertelement <4 x i32> undef, i32 %f, i32 0
2632 %ret = shufflevector <4 x i32> %a0, <4 x i32> <i32 undef, i32 4, i32 5, i32 30>, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
2636 define <4 x float> @PR22377(<4 x float> %a, <4 x float> %b) {
2637 ; SSE2-LABEL: PR22377:
2638 ; SSE2: # %bb.0: # %entry
2639 ; SSE2-NEXT: movaps %xmm0, %xmm1
2640 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,3],xmm0[2,3]
2641 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2,0,2]
2642 ; SSE2-NEXT: addps %xmm0, %xmm1
2643 ; SSE2-NEXT: unpcklps {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
2646 ; SSSE3-LABEL: PR22377:
2647 ; SSSE3: # %bb.0: # %entry
2648 ; SSSE3-NEXT: movaps %xmm0, %xmm1
2649 ; SSSE3-NEXT: haddps %xmm0, %xmm1
2650 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,1]
2651 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2,1,3]
2654 ; SSE41-LABEL: PR22377:
2655 ; SSE41: # %bb.0: # %entry
2656 ; SSE41-NEXT: movaps %xmm0, %xmm1
2657 ; SSE41-NEXT: haddps %xmm0, %xmm1
2658 ; SSE41-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,1]
2659 ; SSE41-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2,1,3]
2662 ; AVX-LABEL: PR22377:
2663 ; AVX: # %bb.0: # %entry
2664 ; AVX-NEXT: vhaddps %xmm0, %xmm0, %xmm1
2665 ; AVX-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,1]
2666 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,1,3]
2669 %s1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 1, i32 3, i32 1, i32 3>
2670 %s2 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 0, i32 2, i32 0, i32 2>
2671 %r2 = fadd <4 x float> %s1, %s2
2672 %s3 = shufflevector <4 x float> %s2, <4 x float> %r2, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
2676 define <4 x float> @PR22390(<4 x float> %a, <4 x float> %b) {
2677 ; SSE2-LABEL: PR22390:
2678 ; SSE2: # %bb.0: # %entry
2679 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,0,1,2]
2680 ; SSE2-NEXT: movaps %xmm0, %xmm2
2681 ; SSE2-NEXT: movss {{.*#+}} xmm2 = xmm1[0],xmm2[1,2,3]
2682 ; SSE2-NEXT: addps %xmm0, %xmm2
2683 ; SSE2-NEXT: movaps %xmm2, %xmm0
2686 ; SSSE3-LABEL: PR22390:
2687 ; SSSE3: # %bb.0: # %entry
2688 ; SSSE3-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,0,1,2]
2689 ; SSSE3-NEXT: movaps %xmm0, %xmm2
2690 ; SSSE3-NEXT: movss {{.*#+}} xmm2 = xmm1[0],xmm2[1,2,3]
2691 ; SSSE3-NEXT: addps %xmm0, %xmm2
2692 ; SSSE3-NEXT: movaps %xmm2, %xmm0
2695 ; SSE41-LABEL: PR22390:
2696 ; SSE41: # %bb.0: # %entry
2697 ; SSE41-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,0,1,2]
2698 ; SSE41-NEXT: blendps {{.*#+}} xmm1 = xmm1[0],xmm0[1,2,3]
2699 ; SSE41-NEXT: addps %xmm1, %xmm0
2702 ; AVX-LABEL: PR22390:
2703 ; AVX: # %bb.0: # %entry
2704 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[3,0,1,2]
2705 ; AVX-NEXT: vblendps {{.*#+}} xmm1 = xmm1[0],xmm0[1,2,3]
2706 ; AVX-NEXT: vaddps %xmm1, %xmm0, %xmm0
2709 %s1 = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
2710 %s2 = shufflevector <4 x float> %s1, <4 x float> %b, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
2711 %r2 = fadd <4 x float> %s1, %s2
2715 define <8 x float> @PR22412(<8 x float> %a, <8 x float> %b) {
2716 ; SSE-LABEL: PR22412:
2717 ; SSE: # %bb.0: # %entry
2718 ; SSE-NEXT: movaps %xmm3, %xmm1
2719 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,0],xmm3[3,2]
2720 ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,0],xmm2[3,2]
2723 ; AVX1-LABEL: PR22412:
2724 ; AVX1: # %bb.0: # %entry
2725 ; AVX1-NEXT: vperm2f128 {{.*#+}} ymm2 = ymm1[2,3,0,1]
2726 ; AVX1-NEXT: vblendps {{.*#+}} ymm0 = ymm0[0,1,2,3],ymm1[4,5,6,7]
2727 ; AVX1-NEXT: vshufps {{.*#+}} ymm0 = ymm0[1,0],ymm2[3,2],ymm0[5,4],ymm2[7,6]
2730 ; AVX2-LABEL: PR22412:
2731 ; AVX2: # %bb.0: # %entry
2732 ; AVX2-NEXT: vblendps {{.*#+}} ymm0 = ymm0[0,1,2,3],ymm1[4,5,6,7]
2733 ; AVX2-NEXT: vpermpd {{.*#+}} ymm1 = ymm1[2,3,0,1]
2734 ; AVX2-NEXT: vshufps {{.*#+}} ymm0 = ymm0[1,0],ymm1[3,2],ymm0[5,4],ymm1[7,6]
2737 %s1 = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 0, i32 1, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
2738 %s2 = shufflevector <8 x float> %s1, <8 x float> undef, <8 x i32> <i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2>
2742 define <4 x float> @PR30264(<4 x float> %x) {
2743 ; SSE2-LABEL: PR30264:
2745 ; SSE2-NEXT: xorps %xmm1, %xmm1
2746 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,0],xmm0[0,0]
2747 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],mem[2,3]
2748 ; SSE2-NEXT: movaps %xmm1, %xmm0
2751 ; SSSE3-LABEL: PR30264:
2753 ; SSSE3-NEXT: xorps %xmm1, %xmm1
2754 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,0],xmm0[0,0]
2755 ; SSSE3-NEXT: shufps {{.*#+}} xmm1 = xmm1[2,0],mem[2,3]
2756 ; SSSE3-NEXT: movaps %xmm1, %xmm0
2759 ; SSE41-LABEL: PR30264:
2761 ; SSE41-NEXT: movaps {{.*#+}} xmm1 = <u,u,4.0E+0,1.0E+0>
2762 ; SSE41-NEXT: insertps {{.*#+}} xmm1 = xmm0[0],zero,xmm1[2,3]
2763 ; SSE41-NEXT: movaps %xmm1, %xmm0
2766 ; AVX-LABEL: PR30264:
2768 ; AVX-NEXT: vmovaps {{.*#+}} xmm1 = <u,u,4.0E+0,1.0E+0>
2769 ; AVX-NEXT: vinsertps {{.*#+}} xmm0 = xmm0[0],zero,xmm1[2,3]
2771 %shuf1 = shufflevector <4 x float> %x, <4 x float> <float undef, float 0.0, float undef, float undef>, <4 x i32> <i32 0, i32 5, i32 undef, i32 undef>
2772 %shuf2 = shufflevector <4 x float> %shuf1, <4 x float> <float undef, float undef, float 4.0, float 1.0>, <4 x i32> <i32 0, i32 1, i32 6, i32 7>
2773 ret <4 x float> %shuf2
2776 define <8 x i16> @PR39549(<16 x i8> %x) {
2777 ; SSE-LABEL: PR39549:
2779 ; SSE-NEXT: punpckhbw {{.*#+}} xmm0 = xmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
2780 ; SSE-NEXT: psraw $8, %xmm0
2783 ; AVX-LABEL: PR39549:
2785 ; AVX-NEXT: vpunpckhbw {{.*#+}} xmm0 = xmm0[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
2786 ; AVX-NEXT: vpsraw $8, %xmm0, %xmm0
2788 %a = shufflevector <16 x i8> %x, <16 x i8> undef, <16 x i32> <i32 8, i32 undef, i32 9, i32 undef, i32 10, i32 undef, i32 11, i32 undef, i32 12, i32 undef, i32 13, i32 undef, i32 14, i32 undef, i32 15, i32 undef>
2789 %b = bitcast <16 x i8> %a to <8 x i16>
2790 %c = shl <8 x i16> %b, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8>
2791 %d = ashr <8 x i16> %c, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8>
2795 define <4 x i32> @PR41545(<4 x i32> %a0, <16 x i8> %a1) {
2796 ; SSE-LABEL: PR41545:
2798 ; SSE-NEXT: paddd %xmm1, %xmm0
2801 ; AVX-LABEL: PR41545:
2803 ; AVX-NEXT: vpaddd %xmm1, %xmm0, %xmm0
2805 %1 = shufflevector <16 x i8> %a1, <16 x i8> undef, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
2806 %2 = shufflevector <16 x i8> %a1, <16 x i8> undef, <4 x i32> <i32 1, i32 5, i32 9, i32 13>
2807 %3 = shufflevector <16 x i8> %a1, <16 x i8> undef, <4 x i32> <i32 2, i32 6, i32 10, i32 14>
2808 %4 = shufflevector <16 x i8> %a1, <16 x i8> undef, <4 x i32> <i32 3, i32 7, i32 11, i32 15>
2809 %5 = zext <4 x i8> %1 to <4 x i32>
2810 %6 = zext <4 x i8> %2 to <4 x i32>
2811 %7 = zext <4 x i8> %3 to <4 x i32>
2812 %8 = zext <4 x i8> %4 to <4 x i32>
2813 %9 = shl <4 x i32> %6, <i32 8, i32 8, i32 8, i32 8>
2814 %10 = shl <4 x i32> %7, <i32 16, i32 16, i32 16, i32 16>
2815 %11 = shl <4 x i32> %8, <i32 24, i32 24, i32 24, i32 24>
2816 %12 = or <4 x i32> %5, %9
2817 %13 = or <4 x i32> %12, %10
2818 %14 = or <4 x i32> %13, %11
2819 %15 = add <4 x i32> %a0, %14
2823 define <8 x i16> @shuffle_extract_insert(<8 x i16> %a) {
2824 ; SSE-LABEL: shuffle_extract_insert:
2826 ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[2,1,0,3,4,5,6,7]
2827 ; SSE-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,6,5,4,7]
2830 ; AVX1-LABEL: shuffle_extract_insert:
2832 ; AVX1-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[2,1,0,3,4,5,6,7]
2833 ; AVX1-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,6,5,4,7]
2836 ; AVX2-SLOW-LABEL: shuffle_extract_insert:
2837 ; AVX2-SLOW: # %bb.0:
2838 ; AVX2-SLOW-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[2,1,0,3,4,5,6,7]
2839 ; AVX2-SLOW-NEXT: vpshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,6,5,4,7]
2840 ; AVX2-SLOW-NEXT: retq
2842 ; AVX2-FAST-LABEL: shuffle_extract_insert:
2843 ; AVX2-FAST: # %bb.0:
2844 ; AVX2-FAST-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[4,5,2,3,0,1,6,7,12,13,10,11,8,9,14,15]
2845 ; AVX2-FAST-NEXT: retq
2846 %a0 = extractelement <8 x i16> %a, i32 0
2847 %a1 = extractelement <8 x i16> %a, i32 1
2848 %a3 = extractelement <8 x i16> %a, i32 3
2849 %a4 = extractelement <8 x i16> %a, i32 4
2850 %a5 = extractelement <8 x i16> %a, i32 5
2851 %a6 = extractelement <8 x i16> %a, i32 6
2852 %a7 = extractelement <8 x i16> %a, i32 7
2853 %1 = shufflevector <8 x i16> %a, <8 x i16> %a, <8 x i32> <i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
2854 %2 = insertelement <8 x i16> %1, i16 %a1, i32 1
2855 %3 = insertelement <8 x i16> %2, i16 %a0, i32 2
2856 %4 = insertelement <8 x i16> %3, i16 %a3, i32 3
2857 %5 = insertelement <8 x i16> %4, i16 %a6, i32 4
2858 %6 = insertelement <8 x i16> %5, i16 %a5, i32 5
2859 %7 = insertelement <8 x i16> %6, i16 %a4, i32 6
2860 %8 = insertelement <8 x i16> %7, i16 %a7, i32 7
2864 define <8 x i16> @shuffle_extract_insert_double(<8 x i16> %a, <8 x i16> %b) {
2865 ; SSE2-LABEL: shuffle_extract_insert_double:
2867 ; SSE2-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,3,2,3,4,5,6,7]
2868 ; SSE2-NEXT: pshufhw {{.*#+}} xmm1 = xmm1[0,1,2,3,7,5,6,7]
2869 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
2870 ; SSE2-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,1,3,2,4,5,6,7]
2871 ; SSE2-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7]
2872 ; SSE2-NEXT: pshufhw {{.*#+}} xmm0 = xmm0[0,1,2,3,4,6,6,7]
2873 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
2874 ; SSE2-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[1,0,3,2,4,5,6,7]
2875 ; SSE2-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
2878 ; SSSE3-LABEL: shuffle_extract_insert_double:
2880 ; SSSE3-NEXT: pshufb {{.*#+}} xmm1 = xmm1[0,1,6,7,10,11,14,15,14,15,10,11,12,13,14,15]
2881 ; SSSE3-NEXT: pshufb {{.*#+}} xmm0 = xmm0[4,5,0,1,12,13,8,9,8,9,12,13,12,13,14,15]
2882 ; SSSE3-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
2885 ; SSE41-LABEL: shuffle_extract_insert_double:
2887 ; SSE41-NEXT: pshufb {{.*#+}} xmm1 = xmm1[0,1,6,7,10,11,14,15,14,15,10,11,12,13,14,15]
2888 ; SSE41-NEXT: pshufb {{.*#+}} xmm0 = xmm0[4,5,0,1,12,13,8,9,8,9,12,13,12,13,14,15]
2889 ; SSE41-NEXT: punpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
2892 ; AVX-LABEL: shuffle_extract_insert_double:
2894 ; AVX-NEXT: vpshufb {{.*#+}} xmm1 = xmm1[0,1,6,7,10,11,14,15,14,15,10,11,12,13,14,15]
2895 ; AVX-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[4,5,0,1,12,13,8,9,8,9,12,13,12,13,14,15]
2896 ; AVX-NEXT: vpunpcklwd {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
2898 %a0 = extractelement <8 x i16> %a, i32 0
2899 %a4 = extractelement <8 x i16> %a, i32 4
2900 %a6 = extractelement <8 x i16> %a, i32 6
2901 %b11 = extractelement <8 x i16> %b, i32 3
2902 %b13 = extractelement <8 x i16> %b, i32 5
2903 %b15 = extractelement <8 x i16> %b, i32 7
2904 %1 = shufflevector <8 x i16> %a, <8 x i16> %b, <8 x i32> <i32 2, i32 8, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
2905 %2 = insertelement <8 x i16> %1, i16 %a0, i32 2
2906 %3 = insertelement <8 x i16> %2, i16 %b11, i32 3
2907 %4 = insertelement <8 x i16> %3, i16 %a6, i32 4
2908 %5 = insertelement <8 x i16> %4, i16 %b13, i32 5
2909 %6 = insertelement <8 x i16> %5, i16 %a4, i32 6
2910 %7 = insertelement <8 x i16> %6, i16 %b15, i32 7