1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE2
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+sse3 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE3
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+ssse3 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSSE3
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+sse4.1 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=SSE --check-prefix=SSE41
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=+avx -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --check-prefix=AVX --check-prefix=AVX1
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-unknown"
10 define <4 x i32> @shuffle_v4i32_0001(<4 x i32> %a, <4 x i32> %b) {
11 ; ALL-LABEL: @shuffle_v4i32_0001
12 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,0,1]
14 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
15 ret <4 x i32> %shuffle
17 define <4 x i32> @shuffle_v4i32_0020(<4 x i32> %a, <4 x i32> %b) {
18 ; ALL-LABEL: @shuffle_v4i32_0020
19 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,0,2,0]
21 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
22 ret <4 x i32> %shuffle
24 define <4 x i32> @shuffle_v4i32_0112(<4 x i32> %a, <4 x i32> %b) {
25 ; ALL-LABEL: @shuffle_v4i32_0112
26 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,1,1,2]
28 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 1, i32 2>
29 ret <4 x i32> %shuffle
31 define <4 x i32> @shuffle_v4i32_0300(<4 x i32> %a, <4 x i32> %b) {
32 ; ALL-LABEL: @shuffle_v4i32_0300
33 ; ALL: pshufd {{.*}} # xmm0 = xmm0[0,3,0,0]
35 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
36 ret <4 x i32> %shuffle
38 define <4 x i32> @shuffle_v4i32_1000(<4 x i32> %a, <4 x i32> %b) {
39 ; ALL-LABEL: @shuffle_v4i32_1000
40 ; ALL: pshufd {{.*}} # xmm0 = xmm0[1,0,0,0]
42 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
43 ret <4 x i32> %shuffle
45 define <4 x i32> @shuffle_v4i32_2200(<4 x i32> %a, <4 x i32> %b) {
46 ; ALL-LABEL: @shuffle_v4i32_2200
47 ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,2,0,0]
49 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
50 ret <4 x i32> %shuffle
52 define <4 x i32> @shuffle_v4i32_3330(<4 x i32> %a, <4 x i32> %b) {
53 ; ALL-LABEL: @shuffle_v4i32_3330
54 ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,3,3,0]
56 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
57 ret <4 x i32> %shuffle
59 define <4 x i32> @shuffle_v4i32_3210(<4 x i32> %a, <4 x i32> %b) {
60 ; ALL-LABEL: @shuffle_v4i32_3210
61 ; ALL: pshufd {{.*}} # xmm0 = xmm0[3,2,1,0]
63 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
64 ret <4 x i32> %shuffle
67 define <4 x i32> @shuffle_v4i32_2121(<4 x i32> %a, <4 x i32> %b) {
68 ; ALL-LABEL: @shuffle_v4i32_2121
69 ; ALL: pshufd {{.*}} # xmm0 = xmm0[2,1,2,1]
71 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 1, i32 2, i32 1>
72 ret <4 x i32> %shuffle
75 define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) {
76 ; ALL-LABEL: @shuffle_v4f32_0001
77 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,0,1]
79 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
80 ret <4 x float> %shuffle
82 define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) {
83 ; ALL-LABEL: @shuffle_v4f32_0020
84 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,0,2,0]
86 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
87 ret <4 x float> %shuffle
89 define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) {
90 ; ALL-LABEL: @shuffle_v4f32_0300
91 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,3,0,0]
93 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
94 ret <4 x float> %shuffle
96 define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) {
97 ; ALL-LABEL: @shuffle_v4f32_1000
98 ; ALL: shufps {{.*}} # xmm0 = xmm0[1,0,0,0]
100 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
101 ret <4 x float> %shuffle
103 define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) {
104 ; ALL-LABEL: @shuffle_v4f32_2200
105 ; ALL: shufps {{.*}} # xmm0 = xmm0[2,2,0,0]
107 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
108 ret <4 x float> %shuffle
110 define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) {
111 ; ALL-LABEL: @shuffle_v4f32_3330
112 ; ALL: shufps {{.*}} # xmm0 = xmm0[3,3,3,0]
114 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
115 ret <4 x float> %shuffle
117 define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) {
118 ; ALL-LABEL: @shuffle_v4f32_3210
119 ; ALL: shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
121 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
122 ret <4 x float> %shuffle
124 define <4 x float> @shuffle_v4f32_0011(<4 x float> %a, <4 x float> %b) {
125 ; ALL-LABEL: @shuffle_v4f32_0011
126 ; ALL: unpcklps {{.*}} # xmm0 = xmm0[0,0,1,1]
128 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
129 ret <4 x float> %shuffle
131 define <4 x float> @shuffle_v4f32_2233(<4 x float> %a, <4 x float> %b) {
132 ; ALL-LABEL: @shuffle_v4f32_2233
133 ; ALL: unpckhps {{.*}} # xmm0 = xmm0[2,2,3,3]
135 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
136 ret <4 x float> %shuffle
138 define <4 x float> @shuffle_v4f32_0022(<4 x float> %a, <4 x float> %b) {
139 ; SSE2-LABEL: @shuffle_v4f32_0022
140 ; SSE2: shufps {{.*}} # xmm0 = xmm0[0,0,2,2]
143 ; SSE3-LABEL: @shuffle_v4f32_0022
144 ; SSE3: movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
147 ; SSSE3-LABEL: @shuffle_v4f32_0022
148 ; SSSE3: movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
151 ; SSE41-LABEL: @shuffle_v4f32_0022
152 ; SSE41: movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
155 ; AVX-LABEL: @shuffle_v4f32_0022
156 ; AVX: vmovsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
158 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
159 ret <4 x float> %shuffle
161 define <4 x float> @shuffle_v4f32_1133(<4 x float> %a, <4 x float> %b) {
162 ; SSE2-LABEL: @shuffle_v4f32_1133
163 ; SSE2: shufps {{.*}} # xmm0 = xmm0[1,1,3,3]
166 ; SSE3-LABEL: @shuffle_v4f32_1133
167 ; SSE3: movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
170 ; SSSE3-LABEL: @shuffle_v4f32_1133
171 ; SSSE3: movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
174 ; SSE41-LABEL: @shuffle_v4f32_1133
175 ; SSE41: movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
178 ; AVX-LABEL: @shuffle_v4f32_1133
179 ; AVX: vmovshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
181 %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
182 ret <4 x float> %shuffle
185 define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) {
186 ; SSE2-LABEL: @shuffle_v4i32_0124
187 ; SSE2: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
188 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
191 ; SSE3-LABEL: @shuffle_v4i32_0124
192 ; SSE3: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
193 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
196 ; SSSE3-LABEL: @shuffle_v4i32_0124
197 ; SSSE3: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
198 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
201 ; SSE41-LABEL: @shuffle_v4i32_0124
202 ; SSE41: insertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
205 ; AVX-LABEL: @shuffle_v4i32_0124
206 ; AVX: vinsertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
208 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
209 ret <4 x i32> %shuffle
211 define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) {
212 ; ALL-LABEL: @shuffle_v4i32_0142
213 ; ALL: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
214 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2]
216 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
217 ret <4 x i32> %shuffle
219 define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) {
220 ; SSE-LABEL: @shuffle_v4i32_0412
221 ; SSE: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
222 ; SSE-NEXT: shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
223 ; SSE-NEXT: movaps %xmm1, %xmm0
226 ; AVX-LABEL: @shuffle_v4i32_0412
227 ; AVX: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
228 ; AVX-NEXT: vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2]
230 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2>
231 ret <4 x i32> %shuffle
233 define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) {
234 ; SSE-LABEL: @shuffle_v4i32_4012
235 ; SSE: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
236 ; SSE-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
237 ; SSE-NEXT: movaps %xmm1, %xmm0
240 ; AVX-LABEL: @shuffle_v4i32_4012
241 ; AVX: vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
242 ; AVX-NEXT: vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2]
244 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2>
245 ret <4 x i32> %shuffle
247 define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) {
248 ; ALL-LABEL: @shuffle_v4i32_0145
249 ; ALL: punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
251 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
252 ret <4 x i32> %shuffle
254 define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) {
255 ; ALL-LABEL: @shuffle_v4i32_0451
256 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
257 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2,3,1]
259 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1>
260 ret <4 x i32> %shuffle
262 define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) {
263 ; SSE-LABEL: @shuffle_v4i32_4501
264 ; SSE: punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
265 ; SSE-NEXT: movdqa %xmm1, %xmm0
268 ; AVX-LABEL: @shuffle_v4i32_4501
269 ; AVX: punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0]
271 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
272 ret <4 x i32> %shuffle
274 define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) {
275 ; ALL-LABEL: @shuffle_v4i32_4015
276 ; ALL: shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
277 ; ALL-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0,1,3]
279 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5>
280 ret <4 x i32> %shuffle
283 define <4 x float> @shuffle_v4f32_4zzz(<4 x float> %a) {
284 ; SSE2-LABEL: @shuffle_v4f32_4zzz
285 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
286 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
287 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
290 ; SSE3-LABEL: @shuffle_v4f32_4zzz
291 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
292 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
293 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
296 ; SSSE3-LABEL: @shuffle_v4f32_4zzz
297 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
298 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
299 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
302 ; SSE41-LABEL: @shuffle_v4f32_4zzz
303 ; SSE41: xorps %[[X:xmm[0-9]+]], %[[X]]
304 ; SSE41-NEXT: blendps {{.*}} # [[X]] = xmm0[0],[[X]][1,2,3]
305 ; SSE41-NEXT: movaps %[[X]], %xmm0
308 ; AVX-LABEL: @shuffle_v4f32_4zzz
309 ; AVX: vxorps %[[X:xmm[0-9]+]], %[[X]]
310 ; AVX-NEXT: vblendps {{.*}} # xmm0 = xmm0[0],[[X]][1,2,3]
312 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
313 ret <4 x float> %shuffle
316 define <4 x float> @shuffle_v4f32_z4zz(<4 x float> %a) {
317 ; SSE2-LABEL: @shuffle_v4f32_z4zz
318 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
319 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
320 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
323 ; SSE3-LABEL: @shuffle_v4f32_z4zz
324 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
325 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
326 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
329 ; SSSE3-LABEL: @shuffle_v4f32_z4zz
330 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
331 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
332 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
335 ; SSE41-LABEL: @shuffle_v4f32_z4zz
336 ; SSE41: insertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
339 ; AVX-LABEL: @shuffle_v4f32_z4zz
340 ; AVX: vinsertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
342 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
343 ret <4 x float> %shuffle
346 define <4 x float> @shuffle_v4f32_zz4z(<4 x float> %a) {
347 ; SSE2-LABEL: @shuffle_v4f32_zz4z
348 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
349 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
350 ; SSE2-NEXT: shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
351 ; SSE2-NEXT: movaps %[[X]], %xmm0
354 ; SSE3-LABEL: @shuffle_v4f32_zz4z
355 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
356 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
357 ; SSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
358 ; SSE3-NEXT: movaps %[[X]], %xmm0
361 ; SSSE3-LABEL: @shuffle_v4f32_zz4z
362 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
363 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
364 ; SSSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
365 ; SSSE3-NEXT: movaps %[[X]], %xmm0
368 ; SSE41-LABEL: @shuffle_v4f32_zz4z
369 ; SSE41: insertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
372 ; AVX-LABEL: @shuffle_v4f32_zz4z
373 ; AVX: vinsertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
375 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
376 ret <4 x float> %shuffle
379 define <4 x float> @shuffle_v4f32_zuu4(<4 x float> %a) {
380 ; SSE2-LABEL: @shuffle_v4f32_zuu4
381 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
382 ; SSE2-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
383 ; SSE2-NEXT: movaps %[[X]], %xmm0
386 ; SSE3-LABEL: @shuffle_v4f32_zuu4
387 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
388 ; SSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
389 ; SSE3-NEXT: movaps %[[X]], %xmm0
392 ; SSSE3-LABEL: @shuffle_v4f32_zuu4
393 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
394 ; SSSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
395 ; SSSE3-NEXT: movaps %[[X]], %xmm0
398 ; SSE41-LABEL: @shuffle_v4f32_zuu4
399 ; SSE41: insertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
402 ; AVX-LABEL: @shuffle_v4f32_zuu4
403 ; AVX: vinsertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
405 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
406 ret <4 x float> %shuffle
409 define <4 x float> @shuffle_v4f32_zzz7(<4 x float> %a) {
410 ; SSE2-LABEL: @shuffle_v4f32_zzz7
411 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
412 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
413 ; SSE2-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
414 ; SSE2-NEXT: movaps %[[X]], %xmm0
417 ; SSE3-LABEL: @shuffle_v4f32_zzz7
418 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
419 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
420 ; SSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
421 ; SSE3-NEXT: movaps %[[X]], %xmm0
424 ; SSSE3-LABEL: @shuffle_v4f32_zzz7
425 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
426 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
427 ; SSSE3-NEXT: shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
428 ; SSSE3-NEXT: movaps %[[X]], %xmm0
431 ; SSE41-LABEL: @shuffle_v4f32_zzz7
432 ; SSE41: xorps %[[X:xmm[0-9]+]], %[[X]]
433 ; SSE41-NEXT: blendps {{.*}} # [[X]] = [[X]][0,1,2],xmm0[3]
434 ; SSE41-NEXT: movaps %[[X]], %xmm0
437 ; AVX-LABEL: @shuffle_v4f32_zzz7
438 ; AVX: vxorps %[[X:xmm[0-9]+]], %[[X]]
439 ; AVX-NEXT: vblendps {{.*}} # xmm0 = [[X]][0,1,2],xmm0[3]
441 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
442 ret <4 x float> %shuffle
445 define <4 x float> @shuffle_v4f32_z6zz(<4 x float> %a) {
446 ; SSE2-LABEL: @shuffle_v4f32_z6zz
447 ; SSE2: xorps %[[X:xmm[0-9]+]], %[[X]]
448 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
449 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
452 ; SSE3-LABEL: @shuffle_v4f32_z6zz
453 ; SSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
454 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
455 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
458 ; SSSE3-LABEL: @shuffle_v4f32_z6zz
459 ; SSSE3: xorps %[[X:xmm[0-9]+]], %[[X]]
460 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
461 ; SSSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
464 ; SSE41-LABEL: @shuffle_v4f32_z6zz
465 ; SSE41: insertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
468 ; AVX-LABEL: @shuffle_v4f32_z6zz
469 ; AVX: vinsertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
471 %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
472 ret <4 x float> %shuffle
475 define <4 x i32> @shuffle_v4i32_4zzz(i32 %i) {
476 ; ALL-LABEL: @shuffle_v4i32_4zzz
477 ; ALL: movd {{.*}}, %xmm0
479 %a = insertelement <4 x i32> undef, i32 %i, i32 0
480 %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
481 ret <4 x i32> %shuffle
484 define <4 x i32> @shuffle_v4i32_z4zz(i32 %i) {
485 ; ALL-LABEL: @shuffle_v4i32_z4zz
486 ; ALL: movd {{.*}}, %xmm0
487 ; ALL-NEXT: pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
489 %a = insertelement <4 x i32> undef, i32 %i, i32 0
490 %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
491 ret <4 x i32> %shuffle
494 define <4 x i32> @shuffle_v4i32_zz4z(i32 %i) {
495 ; ALL-LABEL: @shuffle_v4i32_zz4z
496 ; ALL: movd {{.*}}, %xmm0
497 ; ALL-NEXT: pshufd {{.*}} # xmm0 = xmm0[1,1,0,1]
499 %a = insertelement <4 x i32> undef, i32 %i, i32 0
500 %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
501 ret <4 x i32> %shuffle
504 define <4 x i32> @shuffle_v4i32_zuu4(i32 %i) {
505 ; ALL-LABEL: @shuffle_v4i32_zuu4
506 ; ALL: movd {{.*}}, %xmm0
507 ; ALL-NEXT: pshufd {{.*}} # xmm0 = xmm0[1,1,1,0]
509 %a = insertelement <4 x i32> undef, i32 %i, i32 0
510 %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
511 ret <4 x i32> %shuffle
514 define <4 x i32> @shuffle_v4i32_z6zz(i32 %i) {
515 ; ALL-LABEL: @shuffle_v4i32_z6zz
516 ; ALL: movd {{.*}}, %xmm0
517 ; ALL-NEXT: pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
519 %a = insertelement <4 x i32> undef, i32 %i, i32 2
520 %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
521 ret <4 x i32> %shuffle
524 define <4 x i32> @shuffle_v4i32_7012(<4 x i32> %a, <4 x i32> %b) {
525 ; SSE2-LABEL: @shuffle_v4i32_7012
527 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[3,0],xmm0[0,0]
528 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
529 ; SSE2-NEXT: movaps %xmm1, %xmm0
532 ; SSE3-LABEL: @shuffle_v4i32_7012
534 ; SSE3-NEXT: shufps {{.*}} # xmm1 = xmm1[3,0],xmm0[0,0]
535 ; SSE3-NEXT: shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
536 ; SSE3-NEXT: movaps %xmm1, %xmm0
539 ; SSSE3-LABEL: @shuffle_v4i32_7012
541 ; SSSE3-NEXT: palignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
544 ; SSE41-LABEL: @shuffle_v4i32_7012
546 ; SSE41-NEXT: palignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
549 ; AVX-LABEL: @shuffle_v4i32_7012
551 ; AVX-NEXT: vpalignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
553 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 7, i32 0, i32 1, i32 2>
554 ret <4 x i32> %shuffle
557 define <4 x i32> @shuffle_v4i32_6701(<4 x i32> %a, <4 x i32> %b) {
558 ; SSE2-LABEL: @shuffle_v4i32_6701
560 ; SSE2-NEXT: shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
561 ; SSE2-NEXT: movapd %xmm1, %xmm0
564 ; SSE3-LABEL: @shuffle_v4i32_6701
566 ; SSE3-NEXT: shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
567 ; SSE3-NEXT: movapd %xmm1, %xmm0
570 ; SSSE3-LABEL: @shuffle_v4i32_6701
572 ; SSSE3-NEXT: palignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
575 ; SSE41-LABEL: @shuffle_v4i32_6701
577 ; SSE41-NEXT: palignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
580 ; AVX-LABEL: @shuffle_v4i32_6701
582 ; AVX-NEXT: vpalignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
584 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
585 ret <4 x i32> %shuffle
588 define <4 x i32> @shuffle_v4i32_5670(<4 x i32> %a, <4 x i32> %b) {
589 ; SSE2-LABEL: @shuffle_v4i32_5670
591 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],xmm1[3,0]
592 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[1,2],xmm0[2,0]
593 ; SSE2-NEXT: movaps %xmm1, %xmm0
596 ; SSE3-LABEL: @shuffle_v4i32_5670
598 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,0],xmm1[3,0]
599 ; SSE3-NEXT: shufps {{.*}} # xmm1 = xmm1[1,2],xmm0[2,0]
600 ; SSE3-NEXT: movaps %xmm1, %xmm0
603 ; SSSE3-LABEL: @shuffle_v4i32_5670
605 ; SSSE3-NEXT: palignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
608 ; SSE41-LABEL: @shuffle_v4i32_5670
610 ; SSE41-NEXT: palignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
613 ; AVX-LABEL: @shuffle_v4i32_5670
615 ; AVX-NEXT: vpalignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
617 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 5, i32 6, i32 7, i32 0>
618 ret <4 x i32> %shuffle
621 define <4 x i32> @shuffle_v4i32_1234(<4 x i32> %a, <4 x i32> %b) {
622 ; SSE2-LABEL: @shuffle_v4i32_1234
624 ; SSE2-NEXT: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[3,0]
625 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[1,2],xmm1[2,0]
628 ; SSE3-LABEL: @shuffle_v4i32_1234
630 ; SSE3-NEXT: shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[3,0]
631 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[1,2],xmm1[2,0]
634 ; SSSE3-LABEL: @shuffle_v4i32_1234
636 ; SSSE3-NEXT: palignr $4, {{.*}} # xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
637 ; SSSE3-NEXT: movdqa %xmm1, %xmm0
640 ; SSE41-LABEL: @shuffle_v4i32_1234
642 ; SSE41-NEXT: palignr $4, {{.*}} # xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
643 ; SSE41-NEXT: movdqa %xmm1, %xmm0
646 ; AVX-LABEL: @shuffle_v4i32_1234
648 ; AVX-NEXT: vpalignr $4, {{.*}} # xmm0 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
650 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
651 ret <4 x i32> %shuffle
654 define <4 x i32> @shuffle_v4i32_2345(<4 x i32> %a, <4 x i32> %b) {
655 ; SSE2-LABEL: @shuffle_v4i32_2345
657 ; SSE2-NEXT: shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
660 ; SSE3-LABEL: @shuffle_v4i32_2345
662 ; SSE3-NEXT: shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
665 ; SSSE3-LABEL: @shuffle_v4i32_2345
667 ; SSSE3-NEXT: palignr $8, {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
668 ; SSSE3-NEXT: movdqa %xmm1, %xmm0
671 ; SSE41-LABEL: @shuffle_v4i32_2345
673 ; SSE41-NEXT: palignr $8, {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
674 ; SSE41-NEXT: movdqa %xmm1, %xmm0
677 ; AVX-LABEL: @shuffle_v4i32_2345
679 ; AVX-NEXT: vpalignr $8, {{.*}} # xmm0 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
681 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
682 ret <4 x i32> %shuffle
685 define <4 x i32> @shuffle_v4i32_3456(<4 x i32> %a, <4 x i32> %b) {
686 ; SSE2-LABEL: @shuffle_v4i32_3456
688 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[3,0],xmm1[0,0]
689 ; SSE2-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2],xmm1[1,2]
692 ; SSE3-LABEL: @shuffle_v4i32_3456
694 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[3,0],xmm1[0,0]
695 ; SSE3-NEXT: shufps {{.*}} # xmm0 = xmm0[0,2],xmm1[1,2]
698 ; SSSE3-LABEL: @shuffle_v4i32_3456
700 ; SSSE3-NEXT: palignr $12, {{.*}} # xmm1 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
701 ; SSSE3-NEXT: movdqa %xmm1, %xmm0
704 ; SSE41-LABEL: @shuffle_v4i32_3456
706 ; SSE41-NEXT: palignr $12, {{.*}} # xmm1 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
707 ; SSE41-NEXT: movdqa %xmm1, %xmm0
710 ; AVX-LABEL: @shuffle_v4i32_3456
712 ; AVX-NEXT: vpalignr $12, {{.*}} # xmm0 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
714 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
715 ret <4 x i32> %shuffle
718 define <4 x i32> @shuffle_v4i32_0u1u(<4 x i32> %a, <4 x i32> %b) {
719 ; ALL-LABEL: @shuffle_v4i32_0u1u
721 ; ALL-NEXT: pshufd {{.*}} # xmm0 = xmm0[0,0,1,1]
723 %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 1, i32 undef>
724 ret <4 x i32> %shuffle
727 define <4 x i32> @shuffle_v4i32_0z1z(<4 x i32> %a) {
728 ; SSE2-LABEL: @shuffle_v4i32_0z1z
730 ; SSE2-NEXT: pxor %[[X:xmm[0-9]+]], %[[X]]
731 ; SSE2-NEXT: punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
734 ; SSE3-LABEL: @shuffle_v4i32_0z1z
736 ; SSE3-NEXT: pxor %[[X:xmm[0-9]+]], %[[X]]
737 ; SSE3-NEXT: punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
740 ; SSSE3-LABEL: @shuffle_v4i32_0z1z
742 ; SSSE3-NEXT: pxor %[[X:xmm[0-9]+]], %[[X]]
743 ; SSSE3-NEXT: punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
746 ; SSE41-LABEL: @shuffle_v4i32_0z1z
748 ; SSE41-NEXT: pmovzxdq %xmm0, %xmm0
751 ; AVX-LABEL: @shuffle_v4i32_0z1z
753 ; AVX-NEXT: vpmovzxdq %xmm0, %xmm0
755 %shuffle = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
756 ret <4 x i32> %shuffle
759 define <4 x i32> @insert_reg_and_zero_v4i32(i32 %a) {
760 ; ALL-LABEL: @insert_reg_and_zero_v4i32
762 ; ALL-NEXT: movd %edi, %xmm0
764 %v = insertelement <4 x i32> undef, i32 %a, i32 0
765 %shuffle = shufflevector <4 x i32> %v, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
766 ret <4 x i32> %shuffle
769 define <4 x i32> @insert_mem_and_zero_v4i32(i32* %ptr) {
770 ; ALL-LABEL: @insert_mem_and_zero_v4i32
772 ; ALL-NEXT: movd (%rdi), %xmm0
775 %v = insertelement <4 x i32> undef, i32 %a, i32 0
776 %shuffle = shufflevector <4 x i32> %v, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
777 ret <4 x i32> %shuffle
780 define <4 x float> @insert_reg_and_zero_v4f32(float %a) {
781 ; SSE-LABEL: @insert_reg_and_zero_v4f32
783 ; SSE-NEXT: xorps %[[X:xmm[0-9]+]], %[[X]]
784 ; SSE-NEXT: movss %xmm0, %[[X]]
785 ; SSE-NEXT: movaps %[[X]], %xmm0
788 ; AVX-LABEL: @insert_reg_and_zero_v4f32
790 ; AVX-NEXT: vxorps %[[X:xmm[0-9]+]], %[[X]], %[[X]]
791 ; AVX-NEXT: vmovss %xmm0, %[[X]], %xmm0
793 %v = insertelement <4 x float> undef, float %a, i32 0
794 %shuffle = shufflevector <4 x float> %v, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
795 ret <4 x float> %shuffle
798 define <4 x float> @insert_mem_and_zero_v4f32(float* %ptr) {
799 ; ALL-LABEL: @insert_mem_and_zero_v4f32
801 ; ALL-NEXT: movss (%rdi), %xmm0
803 %a = load float* %ptr
804 %v = insertelement <4 x float> undef, float %a, i32 0
805 %shuffle = shufflevector <4 x float> %v, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
806 ret <4 x float> %shuffle