[x86] Teach the new vector shuffle lowering to use the AVX VPERMILPS
[oota-llvm.git] / test / CodeGen / X86 / vector-shuffle-128-v4.ll
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
6
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-unknown"
9
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]
13 ; ALL-NEXT:    retq
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
16 }
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]
20 ; ALL-NEXT:    retq
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
23 }
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]
27 ; ALL-NEXT:    retq
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
30 }
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]
34 ; ALL-NEXT:    retq
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
37 }
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]
41 ; ALL-NEXT:    retq
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
44 }
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]
48 ; ALL-NEXT:    retq
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
51 }
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]
55 ; ALL-NEXT:    retq
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
58 }
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]
62 ; ALL-NEXT:    retq
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
65 }
66
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]
70 ; ALL-NEXT:    retq
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
73 }
74
75 define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) {
76 ; SSE-LABEL: @shuffle_v4f32_0001
77 ; SSE:       # BB#0:
78 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0,0,1]
79 ; SSE-NEXT:    retq
80 ;
81 ; AVX-LABEL: @shuffle_v4f32_0001
82 ; AVX:       # BB#0:
83 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[0,0,0,1]
84 ; AVX-NEXT:    retq
85   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
86   ret <4 x float> %shuffle
87 }
88 define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) {
89 ; SSE-LABEL: @shuffle_v4f32_0020
90 ; SSE:       # BB#0:
91 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0,2,0]
92 ; SSE-NEXT:    retq
93 ;
94 ; AVX-LABEL: @shuffle_v4f32_0020
95 ; AVX:       # BB#0:
96 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[0,0,2,0]
97 ; AVX-NEXT:    retq
98   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
99   ret <4 x float> %shuffle
100 }
101 define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) {
102 ; SSE-LABEL: @shuffle_v4f32_0300
103 ; SSE:       # BB#0:
104 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,3,0,0]
105 ; SSE-NEXT:    retq
106 ;
107 ; AVX-LABEL: @shuffle_v4f32_0300
108 ; AVX:       # BB#0:
109 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[0,3,0,0]
110 ; AVX-NEXT:    retq
111   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
112   ret <4 x float> %shuffle
113 }
114 define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) {
115 ; SSE-LABEL: @shuffle_v4f32_1000
116 ; SSE:       # BB#0:
117 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[1,0,0,0]
118 ; SSE-NEXT:    retq
119 ;
120 ; AVX-LABEL: @shuffle_v4f32_1000
121 ; AVX:       # BB#0:
122 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[1,0,0,0]
123 ; AVX-NEXT:    retq
124   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
125   ret <4 x float> %shuffle
126 }
127 define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) {
128 ; SSE-LABEL: @shuffle_v4f32_2200
129 ; SSE:       # BB#0:
130 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,2,0,0]
131 ; SSE-NEXT:    retq
132 ;
133 ; AVX-LABEL: @shuffle_v4f32_2200
134 ; AVX:       # BB#0:
135 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[2,2,0,0]
136 ; AVX-NEXT:    retq
137   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
138   ret <4 x float> %shuffle
139 }
140 define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) {
141 ; SSE-LABEL: @shuffle_v4f32_3330
142 ; SSE:       # BB#0:
143 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,3,3,0]
144 ; SSE-NEXT:    retq
145 ;
146 ; AVX-LABEL: @shuffle_v4f32_3330
147 ; AVX:       # BB#0:
148 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[3,3,3,0]
149 ; AVX-NEXT:    retq
150   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
151   ret <4 x float> %shuffle
152 }
153 define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) {
154 ; SSE-LABEL: @shuffle_v4f32_3210
155 ; SSE:       # BB#0:
156 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
157 ; SSE-NEXT:    retq
158 ;
159 ; AVX-LABEL: @shuffle_v4f32_3210
160 ; AVX:       # BB#0:
161 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = xmm0[3,2,1,0]
162 ; AVX-NEXT:    retq
163   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
164   ret <4 x float> %shuffle
165 }
166 define <4 x float> @shuffle_v4f32_0011(<4 x float> %a, <4 x float> %b) {
167 ; ALL-LABEL: @shuffle_v4f32_0011
168 ; ALL:         unpcklps {{.*}} # xmm0 = xmm0[0,0,1,1]
169 ; ALL-NEXT:    retq
170   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
171   ret <4 x float> %shuffle
172 }
173 define <4 x float> @shuffle_v4f32_2233(<4 x float> %a, <4 x float> %b) {
174 ; ALL-LABEL: @shuffle_v4f32_2233
175 ; ALL:         unpckhps {{.*}} # xmm0 = xmm0[2,2,3,3]
176 ; ALL-NEXT:    retq
177   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
178   ret <4 x float> %shuffle
179 }
180 define <4 x float> @shuffle_v4f32_0022(<4 x float> %a, <4 x float> %b) {
181 ; SSE2-LABEL: @shuffle_v4f32_0022
182 ; SSE2:         shufps {{.*}} # xmm0 = xmm0[0,0,2,2]
183 ; SSE2-NEXT:    retq
184 ;
185 ; SSE3-LABEL: @shuffle_v4f32_0022
186 ; SSE3:         movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
187 ; SSE3-NEXT:    retq
188 ;
189 ; SSSE3-LABEL: @shuffle_v4f32_0022
190 ; SSSE3:         movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
191 ; SSSE3-NEXT:    retq
192 ;
193 ; SSE41-LABEL: @shuffle_v4f32_0022
194 ; SSE41:         movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
195 ; SSE41-NEXT:    retq
196 ;
197 ; AVX-LABEL: @shuffle_v4f32_0022
198 ; AVX:         vmovsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
199 ; AVX-NEXT:    retq
200   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
201   ret <4 x float> %shuffle
202 }
203 define <4 x float> @shuffle_v4f32_1133(<4 x float> %a, <4 x float> %b) {
204 ; SSE2-LABEL: @shuffle_v4f32_1133
205 ; SSE2:         shufps {{.*}} # xmm0 = xmm0[1,1,3,3]
206 ; SSE2-NEXT:    retq
207 ;
208 ; SSE3-LABEL: @shuffle_v4f32_1133
209 ; SSE3:         movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
210 ; SSE3-NEXT:    retq
211 ;
212 ; SSSE3-LABEL: @shuffle_v4f32_1133
213 ; SSSE3:         movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
214 ; SSSE3-NEXT:    retq
215 ;
216 ; SSE41-LABEL: @shuffle_v4f32_1133
217 ; SSE41:         movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
218 ; SSE41-NEXT:    retq
219 ;
220 ; AVX-LABEL: @shuffle_v4f32_1133
221 ; AVX:         vmovshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
222 ; AVX-NEXT:    retq
223   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
224   ret <4 x float> %shuffle
225 }
226
227 define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) {
228 ; SSE2-LABEL: @shuffle_v4i32_0124
229 ; SSE2:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
230 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
231 ; SSE2-NEXT:    retq
232 ;
233 ; SSE3-LABEL: @shuffle_v4i32_0124
234 ; SSE3:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
235 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
236 ; SSE3-NEXT:    retq
237 ;
238 ; SSSE3-LABEL: @shuffle_v4i32_0124
239 ; SSSE3:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
240 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
241 ; SSSE3-NEXT:    retq
242 ;
243 ; SSE41-LABEL: @shuffle_v4i32_0124
244 ; SSE41:         insertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
245 ; SSE41-NEXT:    retq
246 ;
247 ; AVX-LABEL: @shuffle_v4i32_0124
248 ; AVX:         vinsertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
249 ; AVX-NEXT:    retq
250   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
251   ret <4 x i32> %shuffle
252 }
253 define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) {
254 ; ALL-LABEL: @shuffle_v4i32_0142
255 ; ALL:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
256 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2]
257 ; ALL-NEXT:    retq
258   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
259   ret <4 x i32> %shuffle
260 }
261 define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) {
262 ; SSE-LABEL: @shuffle_v4i32_0412
263 ; SSE:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
264 ; SSE-NEXT:    shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
265 ; SSE-NEXT:    movaps %xmm1, %xmm0
266 ; SSE-NEXT:    retq
267 ;
268 ; AVX-LABEL: @shuffle_v4i32_0412
269 ; AVX:         vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
270 ; AVX-NEXT:    vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2]
271 ; AVX-NEXT:    retq
272   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2>
273   ret <4 x i32> %shuffle
274 }
275 define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) {
276 ; SSE-LABEL: @shuffle_v4i32_4012
277 ; SSE:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
278 ; SSE-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
279 ; SSE-NEXT:    movaps %xmm1, %xmm0
280 ; SSE-NEXT:    retq
281 ;
282 ; AVX-LABEL: @shuffle_v4i32_4012
283 ; AVX:         vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
284 ; AVX-NEXT:    vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2]
285 ; AVX-NEXT:    retq
286   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2>
287   ret <4 x i32> %shuffle
288 }
289 define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) {
290 ; ALL-LABEL: @shuffle_v4i32_0145
291 ; ALL:         punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
292 ; ALL-NEXT:    retq
293   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
294   ret <4 x i32> %shuffle
295 }
296 define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) {
297 ; ALL-LABEL: @shuffle_v4i32_0451
298 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
299 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2,3,1]
300 ; ALL-NEXT:    retq
301   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1>
302   ret <4 x i32> %shuffle
303 }
304 define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) {
305 ; SSE-LABEL: @shuffle_v4i32_4501
306 ; SSE:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
307 ; SSE-NEXT:    movdqa %xmm1, %xmm0
308 ; SSE-NEXT:    retq
309 ;
310 ; AVX-LABEL: @shuffle_v4i32_4501
311 ; AVX:         punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0]
312 ; AVX-NEXT:    retq
313   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
314   ret <4 x i32> %shuffle
315 }
316 define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) {
317 ; ALL-LABEL: @shuffle_v4i32_4015
318 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
319 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0,1,3]
320 ; ALL-NEXT:    retq
321   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5>
322   ret <4 x i32> %shuffle
323 }
324
325 define <4 x float> @shuffle_v4f32_4zzz(<4 x float> %a) {
326 ; SSE2-LABEL: @shuffle_v4f32_4zzz
327 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
328 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
329 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
330 ; SSE2-NEXT:    retq
331 ;
332 ; SSE3-LABEL: @shuffle_v4f32_4zzz
333 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
334 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
335 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
336 ; SSE3-NEXT:    retq
337 ;
338 ; SSSE3-LABEL: @shuffle_v4f32_4zzz
339 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
340 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
341 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
342 ; SSSE3-NEXT:    retq
343 ;
344 ; SSE41-LABEL: @shuffle_v4f32_4zzz
345 ; SSE41:         xorps %[[X:xmm[0-9]+]], %[[X]]
346 ; SSE41-NEXT:    blendps {{.*}} # [[X]] = xmm0[0],[[X]][1,2,3]
347 ; SSE41-NEXT:    movaps %[[X]], %xmm0
348 ; SSE41-NEXT:    retq
349 ;
350 ; AVX-LABEL: @shuffle_v4f32_4zzz
351 ; AVX:         vxorps %[[X:xmm[0-9]+]], %[[X]]
352 ; AVX-NEXT:    vblendps {{.*}} # xmm0 = xmm0[0],[[X]][1,2,3]
353 ; AVX-NEXT:    retq
354   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
355   ret <4 x float> %shuffle
356 }
357
358 define <4 x float> @shuffle_v4f32_z4zz(<4 x float> %a) {
359 ; SSE2-LABEL: @shuffle_v4f32_z4zz
360 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
361 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
362 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
363 ; SSE2-NEXT:    retq
364 ;
365 ; SSE3-LABEL: @shuffle_v4f32_z4zz
366 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
367 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
368 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
369 ; SSE3-NEXT:    retq
370 ;
371 ; SSSE3-LABEL: @shuffle_v4f32_z4zz
372 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
373 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
374 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
375 ; SSSE3-NEXT:    retq
376 ;
377 ; SSE41-LABEL: @shuffle_v4f32_z4zz
378 ; SSE41:         insertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
379 ; SSE41-NEXT:    retq
380 ;
381 ; AVX-LABEL: @shuffle_v4f32_z4zz
382 ; AVX:         vinsertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
383 ; AVX-NEXT:    retq
384   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
385   ret <4 x float> %shuffle
386 }
387
388 define <4 x float> @shuffle_v4f32_zz4z(<4 x float> %a) {
389 ; SSE2-LABEL: @shuffle_v4f32_zz4z
390 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
391 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
392 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
393 ; SSE2-NEXT:    movaps %[[X]], %xmm0
394 ; SSE2-NEXT:    retq
395 ;
396 ; SSE3-LABEL: @shuffle_v4f32_zz4z
397 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
398 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
399 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
400 ; SSE3-NEXT:    movaps %[[X]], %xmm0
401 ; SSE3-NEXT:    retq
402 ;
403 ; SSSE3-LABEL: @shuffle_v4f32_zz4z
404 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
405 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
406 ; SSSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
407 ; SSSE3-NEXT:    movaps %[[X]], %xmm0
408 ; SSSE3-NEXT:    retq
409 ;
410 ; SSE41-LABEL: @shuffle_v4f32_zz4z
411 ; SSE41:         insertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
412 ; SSE41-NEXT:    retq
413 ;
414 ; AVX-LABEL: @shuffle_v4f32_zz4z
415 ; AVX:         vinsertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
416 ; AVX-NEXT:    retq
417   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
418   ret <4 x float> %shuffle
419 }
420
421 define <4 x float> @shuffle_v4f32_zuu4(<4 x float> %a) {
422 ; SSE2-LABEL: @shuffle_v4f32_zuu4
423 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
424 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
425 ; SSE2-NEXT:    movaps %[[X]], %xmm0
426 ; SSE2-NEXT:    retq
427 ;
428 ; SSE3-LABEL: @shuffle_v4f32_zuu4
429 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
430 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
431 ; SSE3-NEXT:    movaps %[[X]], %xmm0
432 ; SSE3-NEXT:    retq
433 ;
434 ; SSSE3-LABEL: @shuffle_v4f32_zuu4
435 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
436 ; SSSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
437 ; SSSE3-NEXT:    movaps %[[X]], %xmm0
438 ; SSSE3-NEXT:    retq
439 ;
440 ; SSE41-LABEL: @shuffle_v4f32_zuu4
441 ; SSE41:         insertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
442 ; SSE41-NEXT:    retq
443 ;
444 ; AVX-LABEL: @shuffle_v4f32_zuu4
445 ; AVX:         vinsertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
446 ; AVX-NEXT:    retq
447   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
448   ret <4 x float> %shuffle
449 }
450
451 define <4 x float> @shuffle_v4f32_zzz7(<4 x float> %a) {
452 ; SSE2-LABEL: @shuffle_v4f32_zzz7
453 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
454 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
455 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
456 ; SSE2-NEXT:    movaps %[[X]], %xmm0
457 ; SSE2-NEXT:    retq
458 ;
459 ; SSE3-LABEL: @shuffle_v4f32_zzz7
460 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
461 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
462 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
463 ; SSE3-NEXT:    movaps %[[X]], %xmm0
464 ; SSE3-NEXT:    retq
465 ;
466 ; SSSE3-LABEL: @shuffle_v4f32_zzz7
467 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
468 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
469 ; SSSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
470 ; SSSE3-NEXT:    movaps %[[X]], %xmm0
471 ; SSSE3-NEXT:    retq
472 ;
473 ; SSE41-LABEL: @shuffle_v4f32_zzz7
474 ; SSE41:         xorps %[[X:xmm[0-9]+]], %[[X]]
475 ; SSE41-NEXT:    blendps {{.*}} # [[X]] = [[X]][0,1,2],xmm0[3]
476 ; SSE41-NEXT:    movaps %[[X]], %xmm0
477 ; SSE41-NEXT:    retq
478 ;
479 ; AVX-LABEL: @shuffle_v4f32_zzz7
480 ; AVX:         vxorps %[[X:xmm[0-9]+]], %[[X]]
481 ; AVX-NEXT:    vblendps {{.*}} # xmm0 = [[X]][0,1,2],xmm0[3]
482 ; AVX-NEXT:    retq
483   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
484   ret <4 x float> %shuffle
485 }
486
487 define <4 x float> @shuffle_v4f32_z6zz(<4 x float> %a) {
488 ; SSE2-LABEL: @shuffle_v4f32_z6zz
489 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
490 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
491 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
492 ; SSE2-NEXT:    retq
493 ;
494 ; SSE3-LABEL: @shuffle_v4f32_z6zz
495 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
496 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
497 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
498 ; SSE3-NEXT:    retq
499 ;
500 ; SSSE3-LABEL: @shuffle_v4f32_z6zz
501 ; SSSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
502 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
503 ; SSSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
504 ; SSSE3-NEXT:    retq
505 ;
506 ; SSE41-LABEL: @shuffle_v4f32_z6zz
507 ; SSE41:         insertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
508 ; SSE41-NEXT:    retq
509 ;
510 ; AVX-LABEL: @shuffle_v4f32_z6zz
511 ; AVX:         vinsertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
512 ; AVX-NEXT:    retq
513   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
514   ret <4 x float> %shuffle
515 }
516
517 define <4 x i32> @shuffle_v4i32_4zzz(i32 %i) {
518 ; ALL-LABEL: @shuffle_v4i32_4zzz
519 ; ALL:         movd {{.*}}, %xmm0
520 ; ALL-NEXT:    retq
521   %a = insertelement <4 x i32> undef, i32 %i, i32 0
522   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
523   ret <4 x i32> %shuffle
524 }
525
526 define <4 x i32> @shuffle_v4i32_z4zz(i32 %i) {
527 ; ALL-LABEL: @shuffle_v4i32_z4zz
528 ; ALL:         movd {{.*}}, %xmm0
529 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
530 ; ALL-NEXT:    retq
531   %a = insertelement <4 x i32> undef, i32 %i, i32 0
532   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
533   ret <4 x i32> %shuffle
534 }
535
536 define <4 x i32> @shuffle_v4i32_zz4z(i32 %i) {
537 ; ALL-LABEL: @shuffle_v4i32_zz4z
538 ; ALL:         movd {{.*}}, %xmm0
539 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,1,0,1]
540 ; ALL-NEXT:    retq
541   %a = insertelement <4 x i32> undef, i32 %i, i32 0
542   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
543   ret <4 x i32> %shuffle
544 }
545
546 define <4 x i32> @shuffle_v4i32_zuu4(i32 %i) {
547 ; ALL-LABEL: @shuffle_v4i32_zuu4
548 ; ALL:         movd {{.*}}, %xmm0
549 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,1,1,0]
550 ; ALL-NEXT:    retq
551   %a = insertelement <4 x i32> undef, i32 %i, i32 0
552   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
553   ret <4 x i32> %shuffle
554 }
555
556 define <4 x i32> @shuffle_v4i32_z6zz(i32 %i) {
557 ; ALL-LABEL: @shuffle_v4i32_z6zz
558 ; ALL:         movd {{.*}}, %xmm0
559 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
560 ; ALL-NEXT:    retq
561   %a = insertelement <4 x i32> undef, i32 %i, i32 2
562   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
563   ret <4 x i32> %shuffle
564 }
565
566 define <4 x i32> @shuffle_v4i32_7012(<4 x i32> %a, <4 x i32> %b) {
567 ; SSE2-LABEL: @shuffle_v4i32_7012
568 ; SSE2:       # BB#0:
569 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[3,0],xmm0[0,0]
570 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
571 ; SSE2-NEXT:    movaps %xmm1, %xmm0
572 ; SSE2-NEXT:    retq
573 ;
574 ; SSE3-LABEL: @shuffle_v4i32_7012
575 ; SSE3:       # BB#0:
576 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[3,0],xmm0[0,0]
577 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
578 ; SSE3-NEXT:    movaps %xmm1, %xmm0
579 ; SSE3-NEXT:    retq
580 ;
581 ; SSSE3-LABEL: @shuffle_v4i32_7012
582 ; SSSE3:       # BB#0:
583 ; SSSE3-NEXT:    palignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
584 ; SSSE3-NEXT:    retq
585 ;
586 ; SSE41-LABEL: @shuffle_v4i32_7012
587 ; SSE41:       # BB#0:
588 ; SSE41-NEXT:    palignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
589 ; SSE41-NEXT:    retq
590 ;
591 ; AVX-LABEL: @shuffle_v4i32_7012
592 ; AVX:       # BB#0:
593 ; AVX-NEXT:    vpalignr $12, {{.*}} # xmm0 = xmm1[12,13,14,15],xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
594 ; AVX-NEXT:    retq
595   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 7, i32 0, i32 1, i32 2>
596   ret <4 x i32> %shuffle
597 }
598
599 define <4 x i32> @shuffle_v4i32_6701(<4 x i32> %a, <4 x i32> %b) {
600 ; SSE2-LABEL: @shuffle_v4i32_6701
601 ; SSE2:       # BB#0:
602 ; SSE2-NEXT:    shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
603 ; SSE2-NEXT:    movapd %xmm1, %xmm0
604 ; SSE2-NEXT:    retq
605 ;
606 ; SSE3-LABEL: @shuffle_v4i32_6701
607 ; SSE3:       # BB#0:
608 ; SSE3-NEXT:    shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
609 ; SSE3-NEXT:    movapd %xmm1, %xmm0
610 ; SSE3-NEXT:    retq
611 ;
612 ; SSSE3-LABEL: @shuffle_v4i32_6701
613 ; SSSE3:       # BB#0:
614 ; SSSE3-NEXT:    palignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
615 ; SSSE3-NEXT:    retq
616 ;
617 ; SSE41-LABEL: @shuffle_v4i32_6701
618 ; SSE41:       # BB#0:
619 ; SSE41-NEXT:    palignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
620 ; SSE41-NEXT:    retq
621 ;
622 ; AVX-LABEL: @shuffle_v4i32_6701
623 ; AVX:       # BB#0:
624 ; AVX-NEXT:    vpalignr $8, {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
625 ; AVX-NEXT:    retq
626   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 6, i32 7, i32 0, i32 1>
627   ret <4 x i32> %shuffle
628 }
629
630 define <4 x i32> @shuffle_v4i32_5670(<4 x i32> %a, <4 x i32> %b) {
631 ; SSE2-LABEL: @shuffle_v4i32_5670
632 ; SSE2:       # BB#0:
633 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],xmm1[3,0]
634 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[1,2],xmm0[2,0]
635 ; SSE2-NEXT:    movaps %xmm1, %xmm0
636 ; SSE2-NEXT:    retq
637 ;
638 ; SSE3-LABEL: @shuffle_v4i32_5670
639 ; SSE3:       # BB#0:
640 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],xmm1[3,0]
641 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[1,2],xmm0[2,0]
642 ; SSE3-NEXT:    movaps %xmm1, %xmm0
643 ; SSE3-NEXT:    retq
644 ;
645 ; SSSE3-LABEL: @shuffle_v4i32_5670
646 ; SSSE3:       # BB#0:
647 ; SSSE3-NEXT:    palignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
648 ; SSSE3-NEXT:    retq
649 ;
650 ; SSE41-LABEL: @shuffle_v4i32_5670
651 ; SSE41:       # BB#0:
652 ; SSE41-NEXT:    palignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
653 ; SSE41-NEXT:    retq
654 ;
655 ; AVX-LABEL: @shuffle_v4i32_5670
656 ; AVX:       # BB#0:
657 ; AVX-NEXT:    vpalignr $4, {{.*}} # xmm0 = xmm1[4,5,6,7,8,9,10,11,12,13,14,15],xmm0[0,1,2,3]
658 ; AVX-NEXT:    retq
659   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 5, i32 6, i32 7, i32 0>
660   ret <4 x i32> %shuffle
661 }
662
663 define <4 x i32> @shuffle_v4i32_1234(<4 x i32> %a, <4 x i32> %b) {
664 ; SSE2-LABEL: @shuffle_v4i32_1234
665 ; SSE2:       # BB#0:
666 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[3,0]
667 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[1,2],xmm1[2,0]
668 ; SSE2-NEXT:    retq
669 ;
670 ; SSE3-LABEL: @shuffle_v4i32_1234
671 ; SSE3:       # BB#0:
672 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[3,0]
673 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[1,2],xmm1[2,0]
674 ; SSE3-NEXT:    retq
675 ;
676 ; SSSE3-LABEL: @shuffle_v4i32_1234
677 ; SSSE3:       # BB#0:
678 ; SSSE3-NEXT:    palignr $4, {{.*}} # xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
679 ; SSSE3-NEXT:    movdqa %xmm1, %xmm0
680 ; SSSE3-NEXT:    retq
681 ;
682 ; SSE41-LABEL: @shuffle_v4i32_1234
683 ; SSE41:       # BB#0:
684 ; SSE41-NEXT:    palignr $4, {{.*}} # xmm1 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
685 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
686 ; SSE41-NEXT:    retq
687 ;
688 ; AVX-LABEL: @shuffle_v4i32_1234
689 ; AVX:       # BB#0:
690 ; AVX-NEXT:    vpalignr $4, {{.*}} # xmm0 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],xmm1[0,1,2,3]
691 ; AVX-NEXT:    retq
692   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 2, i32 3, i32 4>
693   ret <4 x i32> %shuffle
694 }
695
696 define <4 x i32> @shuffle_v4i32_2345(<4 x i32> %a, <4 x i32> %b) {
697 ; SSE2-LABEL: @shuffle_v4i32_2345
698 ; SSE2:       # BB#0:
699 ; SSE2-NEXT:    shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
700 ; SSE2-NEXT:    retq
701 ;
702 ; SSE3-LABEL: @shuffle_v4i32_2345
703 ; SSE3:       # BB#0:
704 ; SSE3-NEXT:    shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
705 ; SSE3-NEXT:    retq
706 ;
707 ; SSSE3-LABEL: @shuffle_v4i32_2345
708 ; SSSE3:       # BB#0:
709 ; SSSE3-NEXT:    palignr $8, {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
710 ; SSSE3-NEXT:    movdqa %xmm1, %xmm0
711 ; SSSE3-NEXT:    retq
712 ;
713 ; SSE41-LABEL: @shuffle_v4i32_2345
714 ; SSE41:       # BB#0:
715 ; SSE41-NEXT:    palignr $8, {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
716 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
717 ; SSE41-NEXT:    retq
718 ;
719 ; AVX-LABEL: @shuffle_v4i32_2345
720 ; AVX:       # BB#0:
721 ; AVX-NEXT:    vpalignr $8, {{.*}} # xmm0 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
722 ; AVX-NEXT:    retq
723   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 3, i32 4, i32 5>
724   ret <4 x i32> %shuffle
725 }
726
727 define <4 x i32> @shuffle_v4i32_3456(<4 x i32> %a, <4 x i32> %b) {
728 ; SSE2-LABEL: @shuffle_v4i32_3456
729 ; SSE2:       # BB#0:
730 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],xmm1[0,0]
731 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],xmm1[1,2]
732 ; SSE2-NEXT:    retq
733 ;
734 ; SSE3-LABEL: @shuffle_v4i32_3456
735 ; SSE3:       # BB#0:
736 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],xmm1[0,0]
737 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],xmm1[1,2]
738 ; SSE3-NEXT:    retq
739 ;
740 ; SSSE3-LABEL: @shuffle_v4i32_3456
741 ; SSSE3:       # BB#0:
742 ; SSSE3-NEXT:    palignr $12, {{.*}} # xmm1 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
743 ; SSSE3-NEXT:    movdqa %xmm1, %xmm0
744 ; SSSE3-NEXT:    retq
745 ;
746 ; SSE41-LABEL: @shuffle_v4i32_3456
747 ; SSE41:       # BB#0:
748 ; SSE41-NEXT:    palignr $12, {{.*}} # xmm1 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
749 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
750 ; SSE41-NEXT:    retq
751 ;
752 ; AVX-LABEL: @shuffle_v4i32_3456
753 ; AVX:       # BB#0:
754 ; AVX-NEXT:    vpalignr $12, {{.*}} # xmm0 = xmm0[12,13,14,15],xmm1[0,1,2,3,4,5,6,7,8,9,10,11]
755 ; AVX-NEXT:    retq
756   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
757   ret <4 x i32> %shuffle
758 }
759
760 define <4 x i32> @shuffle_v4i32_0u1u(<4 x i32> %a, <4 x i32> %b) {
761 ; ALL-LABEL: @shuffle_v4i32_0u1u
762 ; ALL:       # BB#0:
763 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[0,0,1,1]
764 ; ALL-NEXT:    retq
765   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 1, i32 undef>
766   ret <4 x i32> %shuffle
767 }
768
769 define <4 x i32> @shuffle_v4i32_0z1z(<4 x i32> %a) {
770 ; SSE2-LABEL: @shuffle_v4i32_0z1z
771 ; SSE2:       # BB#0:
772 ; SSE2-NEXT:    pxor %[[X:xmm[0-9]+]], %[[X]]
773 ; SSE2-NEXT:    punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
774 ; SSE2-NEXT:    retq
775 ;
776 ; SSE3-LABEL: @shuffle_v4i32_0z1z
777 ; SSE3:       # BB#0:
778 ; SSE3-NEXT:    pxor %[[X:xmm[0-9]+]], %[[X]]
779 ; SSE3-NEXT:    punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
780 ; SSE3-NEXT:    retq
781 ;
782 ; SSSE3-LABEL: @shuffle_v4i32_0z1z
783 ; SSSE3:       # BB#0:
784 ; SSSE3-NEXT:    pxor %[[X:xmm[0-9]+]], %[[X]]
785 ; SSSE3-NEXT:    punpckldq {{.*}} # xmm0 = xmm0[0],[[X]][0],xmm0[1],[[X]][1]
786 ; SSSE3-NEXT:    retq
787 ;
788 ; SSE41-LABEL: @shuffle_v4i32_0z1z
789 ; SSE41:       # BB#0:
790 ; SSE41-NEXT:    pmovzxdq %xmm0, %xmm0
791 ; SSE41-NEXT:    retq
792 ;
793 ; AVX-LABEL: @shuffle_v4i32_0z1z
794 ; AVX:       # BB#0:
795 ; AVX-NEXT:    vpmovzxdq %xmm0, %xmm0
796 ; AVX-NEXT:    retq
797   %shuffle = shufflevector <4 x i32> %a, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 1, i32 7>
798   ret <4 x i32> %shuffle
799 }
800
801 define <4 x i32> @insert_reg_and_zero_v4i32(i32 %a) {
802 ; ALL-LABEL: @insert_reg_and_zero_v4i32
803 ; ALL:       # BB#0:
804 ; ALL-NEXT:    movd %edi, %xmm0
805 ; ALL-NEXT:    retq
806   %v = insertelement <4 x i32> undef, i32 %a, i32 0
807   %shuffle = shufflevector <4 x i32> %v, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
808   ret <4 x i32> %shuffle
809 }
810
811 define <4 x i32> @insert_mem_and_zero_v4i32(i32* %ptr) {
812 ; ALL-LABEL: @insert_mem_and_zero_v4i32
813 ; ALL:       # BB#0:
814 ; ALL-NEXT:    movd (%rdi), %xmm0
815 ; ALL-NEXT:    retq
816   %a = load i32* %ptr
817   %v = insertelement <4 x i32> undef, i32 %a, i32 0
818   %shuffle = shufflevector <4 x i32> %v, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
819   ret <4 x i32> %shuffle
820 }
821
822 define <4 x float> @insert_reg_and_zero_v4f32(float %a) {
823 ; SSE-LABEL: @insert_reg_and_zero_v4f32
824 ; SSE:       # BB#0:
825 ; SSE-NEXT:    xorps %[[X:xmm[0-9]+]], %[[X]]
826 ; SSE-NEXT:    movss %xmm0, %[[X]]
827 ; SSE-NEXT:    movaps %[[X]], %xmm0
828 ; SSE-NEXT:    retq
829 ;
830 ; AVX-LABEL: @insert_reg_and_zero_v4f32
831 ; AVX:       # BB#0:
832 ; AVX-NEXT:    vxorps %[[X:xmm[0-9]+]], %[[X]], %[[X]]
833 ; AVX-NEXT:    vmovss %xmm0, %[[X]], %xmm0
834 ; AVX-NEXT:    retq
835   %v = insertelement <4 x float> undef, float %a, i32 0
836   %shuffle = shufflevector <4 x float> %v, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
837   ret <4 x float> %shuffle
838 }
839
840 define <4 x float> @insert_mem_and_zero_v4f32(float* %ptr) {
841 ; ALL-LABEL: @insert_mem_and_zero_v4f32
842 ; ALL:       # BB#0:
843 ; ALL-NEXT:    movss (%rdi), %xmm0
844 ; ALL-NEXT:    retq
845   %a = load float* %ptr
846   %v = insertelement <4 x float> undef, float %a, i32 0
847   %shuffle = shufflevector <4 x float> %v, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 5, i32 6, i32 7>
848   ret <4 x float> %shuffle
849 }
850
851 define <4 x float> @shuffle_mem_v4f32_3210(<4 x float>* %ptr) {
852 ; SSE-LABEL: @shuffle_mem_v4f32_3210
853 ; SSE:       # BB#0:
854 ; SSE-NEXT:    movaps (%rdi), %xmm0
855 ; SSE-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
856 ; SSE-NEXT:    retq
857 ;
858 ; AVX-LABEL: @shuffle_mem_v4f32_3210
859 ; AVX:       # BB#0:
860 ; AVX-NEXT:    vpermilps {{.*}} # xmm0 = mem[3,2,1,0]
861 ; AVX-NEXT:    retq
862   %a = load <4 x float>* %ptr
863   %shuffle = shufflevector <4 x float> %a, <4 x float> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
864   ret <4 x float> %shuffle
865 }