[x86] Add an explicit SSE3 run to this test and flesh out a bunch of
[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=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=SSE3
3 ; 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=SSE41
4 ; 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=AVX1
5
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-unknown"
8
9 define <4 x i32> @shuffle_v4i32_0001(<4 x i32> %a, <4 x i32> %b) {
10 ; ALL-LABEL: @shuffle_v4i32_0001
11 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[0,0,0,1]
12 ; ALL-NEXT:    retq
13   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
14   ret <4 x i32> %shuffle
15 }
16 define <4 x i32> @shuffle_v4i32_0020(<4 x i32> %a, <4 x i32> %b) {
17 ; ALL-LABEL: @shuffle_v4i32_0020
18 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[0,0,2,0]
19 ; ALL-NEXT:    retq
20   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
21   ret <4 x i32> %shuffle
22 }
23 define <4 x i32> @shuffle_v4i32_0112(<4 x i32> %a, <4 x i32> %b) {
24 ; ALL-LABEL: @shuffle_v4i32_0112
25 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[0,1,1,2]
26 ; ALL-NEXT:    retq
27   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 1, i32 2>
28   ret <4 x i32> %shuffle
29 }
30 define <4 x i32> @shuffle_v4i32_0300(<4 x i32> %a, <4 x i32> %b) {
31 ; ALL-LABEL: @shuffle_v4i32_0300
32 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[0,3,0,0]
33 ; ALL-NEXT:    retq
34   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
35   ret <4 x i32> %shuffle
36 }
37 define <4 x i32> @shuffle_v4i32_1000(<4 x i32> %a, <4 x i32> %b) {
38 ; ALL-LABEL: @shuffle_v4i32_1000
39 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[1,0,0,0]
40 ; ALL-NEXT:    retq
41   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
42   ret <4 x i32> %shuffle
43 }
44 define <4 x i32> @shuffle_v4i32_2200(<4 x i32> %a, <4 x i32> %b) {
45 ; ALL-LABEL: @shuffle_v4i32_2200
46 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[2,2,0,0]
47 ; ALL-NEXT:    retq
48   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
49   ret <4 x i32> %shuffle
50 }
51 define <4 x i32> @shuffle_v4i32_3330(<4 x i32> %a, <4 x i32> %b) {
52 ; ALL-LABEL: @shuffle_v4i32_3330
53 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[3,3,3,0]
54 ; ALL-NEXT:    retq
55   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
56   ret <4 x i32> %shuffle
57 }
58 define <4 x i32> @shuffle_v4i32_3210(<4 x i32> %a, <4 x i32> %b) {
59 ; ALL-LABEL: @shuffle_v4i32_3210
60 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[3,2,1,0]
61 ; ALL-NEXT:    retq
62   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
63   ret <4 x i32> %shuffle
64 }
65
66 define <4 x i32> @shuffle_v4i32_2121(<4 x i32> %a, <4 x i32> %b) {
67 ; ALL-LABEL: @shuffle_v4i32_2121
68 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[2,1,2,1]
69 ; ALL-NEXT:    retq
70   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 1, i32 2, i32 1>
71   ret <4 x i32> %shuffle
72 }
73
74 define <4 x float> @shuffle_v4f32_0001(<4 x float> %a, <4 x float> %b) {
75 ; ALL-LABEL: @shuffle_v4f32_0001
76 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,0,0,1]
77 ; ALL-NEXT:    retq
78   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
79   ret <4 x float> %shuffle
80 }
81 define <4 x float> @shuffle_v4f32_0020(<4 x float> %a, <4 x float> %b) {
82 ; ALL-LABEL: @shuffle_v4f32_0020
83 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,0,2,0]
84 ; ALL-NEXT:    retq
85   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 0>
86   ret <4 x float> %shuffle
87 }
88 define <4 x float> @shuffle_v4f32_0300(<4 x float> %a, <4 x float> %b) {
89 ; ALL-LABEL: @shuffle_v4f32_0300
90 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,3,0,0]
91 ; ALL-NEXT:    retq
92   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 3, i32 0, i32 0>
93   ret <4 x float> %shuffle
94 }
95 define <4 x float> @shuffle_v4f32_1000(<4 x float> %a, <4 x float> %b) {
96 ; ALL-LABEL: @shuffle_v4f32_1000
97 ; ALL:         shufps {{.*}} # xmm0 = xmm0[1,0,0,0]
98 ; ALL-NEXT:    retq
99   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 0, i32 0, i32 0>
100   ret <4 x float> %shuffle
101 }
102 define <4 x float> @shuffle_v4f32_2200(<4 x float> %a, <4 x float> %b) {
103 ; ALL-LABEL: @shuffle_v4f32_2200
104 ; ALL:         shufps {{.*}} # xmm0 = xmm0[2,2,0,0]
105 ; ALL-NEXT:    retq
106   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
107   ret <4 x float> %shuffle
108 }
109 define <4 x float> @shuffle_v4f32_3330(<4 x float> %a, <4 x float> %b) {
110 ; ALL-LABEL: @shuffle_v4f32_3330
111 ; ALL:         shufps {{.*}} # xmm0 = xmm0[3,3,3,0]
112 ; ALL-NEXT:    retq
113   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 3, i32 3, i32 0>
114   ret <4 x float> %shuffle
115 }
116 define <4 x float> @shuffle_v4f32_3210(<4 x float> %a, <4 x float> %b) {
117 ; ALL-LABEL: @shuffle_v4f32_3210
118 ; ALL:         shufps {{.*}} # xmm0 = xmm0[3,2,1,0]
119 ; ALL-NEXT:    retq
120   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
121   ret <4 x float> %shuffle
122 }
123 define <4 x float> @shuffle_v4f32_0011(<4 x float> %a, <4 x float> %b) {
124 ; ALL-LABEL: @shuffle_v4f32_0011
125 ; ALL:         unpcklps {{.*}} # xmm0 = xmm0[0,0,1,1]
126 ; ALL-NEXT:    retq
127   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
128   ret <4 x float> %shuffle
129 }
130 define <4 x float> @shuffle_v4f32_2233(<4 x float> %a, <4 x float> %b) {
131 ; ALL-LABEL: @shuffle_v4f32_2233
132 ; ALL:         unpckhps {{.*}} # xmm0 = xmm0[2,2,3,3]
133 ; ALL-NEXT:    retq
134   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
135   ret <4 x float> %shuffle
136 }
137 define <4 x float> @shuffle_v4f32_0022(<4 x float> %a, <4 x float> %b) {
138 ; SSE2-LABEL: @shuffle_v4f32_0022
139 ; SSE2:         shufps {{.*}} # xmm0 = xmm0[0,0,2,2]
140 ; SSE2-NEXT:    retq
141 ;
142 ; SSE3-LABEL: @shuffle_v4f32_0022
143 ; SSE3:         movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
144 ; SSE3-NEXT:    retq
145 ;
146 ; SSE41-LABEL: @shuffle_v4f32_0022
147 ; SSE41:         movsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
148 ; SSE41-NEXT:    retq
149 ;
150 ; AVX1-LABEL: @shuffle_v4f32_0022
151 ; AVX1:         vmovsldup {{.*}} # xmm0 = xmm0[0,0,2,2]
152 ; AVX1-NEXT:    retq
153   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
154   ret <4 x float> %shuffle
155 }
156 define <4 x float> @shuffle_v4f32_1133(<4 x float> %a, <4 x float> %b) {
157 ; SSE2-LABEL: @shuffle_v4f32_1133
158 ; SSE2:         shufps {{.*}} # xmm0 = xmm0[1,1,3,3]
159 ; SSE2-NEXT:    retq
160 ;
161 ; SSE3-LABEL: @shuffle_v4f32_1133
162 ; SSE3:         movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
163 ; SSE3-NEXT:    retq
164 ;
165 ; SSE41-LABEL: @shuffle_v4f32_1133
166 ; SSE41:         movshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
167 ; SSE41-NEXT:    retq
168 ;
169 ; AVX1-LABEL: @shuffle_v4f32_1133
170 ; AVX1:         vmovshdup {{.*}} # xmm0 = xmm0[1,1,3,3]
171 ; AVX1-NEXT:    retq
172   %shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
173   ret <4 x float> %shuffle
174 }
175
176 define <4 x i32> @shuffle_v4i32_0124(<4 x i32> %a, <4 x i32> %b) {
177 ; SSE2-LABEL: @shuffle_v4i32_0124
178 ; SSE2:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
179 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
180 ; SSE2-NEXT:    retq
181 ;
182 ; SSE3-LABEL: @shuffle_v4i32_0124
183 ; SSE3:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
184 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[2,0]
185 ; SSE3-NEXT:    retq
186 ;
187 ; SSE41-LABEL: @shuffle_v4i32_0124
188 ; SSE41:         insertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
189 ; SSE41-NEXT:    retq
190 ;
191 ; AVX1-LABEL: @shuffle_v4i32_0124
192 ; AVX1:         vinsertps {{.*}} # xmm0 = xmm0[0,1,2],xmm1[0]
193 ; AVX1-NEXT:    retq
194   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
195   ret <4 x i32> %shuffle
196 }
197 define <4 x i32> @shuffle_v4i32_0142(<4 x i32> %a, <4 x i32> %b) {
198 ; ALL-LABEL: @shuffle_v4i32_0142
199 ; ALL:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[2,0]
200 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,2]
201 ; ALL-NEXT:    retq
202   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 2>
203   ret <4 x i32> %shuffle
204 }
205 define <4 x i32> @shuffle_v4i32_0412(<4 x i32> %a, <4 x i32> %b) {
206 ; SSE2-LABEL: @shuffle_v4i32_0412
207 ; SSE2:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
208 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
209 ; SSE2-NEXT:    movaps %xmm1, %xmm0
210 ; SSE2-NEXT:    retq
211 ;
212 ; SSE3-LABEL: @shuffle_v4i32_0412
213 ; SSE3:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
214 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
215 ; SSE3-NEXT:    movaps %xmm1, %xmm0
216 ; SSE3-NEXT:    retq
217 ;
218 ; SSE41-LABEL: @shuffle_v4i32_0412
219 ; SSE41:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
220 ; SSE41-NEXT:    shufps {{.*}} # xmm1 = xmm1[2,0],xmm0[1,2]
221 ; SSE41-NEXT:    movaps %xmm1, %xmm0
222 ; SSE41-NEXT:    retq
223 ;
224 ; AVX1-LABEL: @shuffle_v4i32_0412
225 ; AVX1:         vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
226 ; AVX1-NEXT:    vshufps {{.*}} # xmm0 = xmm1[2,0],xmm0[1,2]
227 ; AVX1-NEXT:    retq
228   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 2>
229   ret <4 x i32> %shuffle
230 }
231 define <4 x i32> @shuffle_v4i32_4012(<4 x i32> %a, <4 x i32> %b) {
232 ; SSE2-LABEL: @shuffle_v4i32_4012
233 ; SSE2:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
234 ; SSE2-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
235 ; SSE2-NEXT:    movaps %xmm1, %xmm0
236 ; SSE2-NEXT:    retq
237 ;
238 ; SSE3-LABEL: @shuffle_v4i32_4012
239 ; SSE3:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
240 ; SSE3-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
241 ; SSE3-NEXT:    movaps %xmm1, %xmm0
242 ; SSE3-NEXT:    retq
243 ;
244 ; SSE41-LABEL: @shuffle_v4i32_4012
245 ; SSE41:         shufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
246 ; SSE41-NEXT:    shufps {{.*}} # xmm1 = xmm1[0,2],xmm0[1,2]
247 ; SSE41-NEXT:    movaps %xmm1, %xmm0
248 ; SSE41-NEXT:    retq
249 ;
250 ; AVX1-LABEL: @shuffle_v4i32_4012
251 ; AVX1:         vshufps {{.*}} # xmm1 = xmm1[0,0],xmm0[0,0]
252 ; AVX1-NEXT:    vshufps {{.*}} # xmm0 = xmm1[0,2],xmm0[1,2]
253 ; AVX1-NEXT:    retq
254   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 2>
255   ret <4 x i32> %shuffle
256 }
257 define <4 x i32> @shuffle_v4i32_0145(<4 x i32> %a, <4 x i32> %b) {
258 ; ALL-LABEL: @shuffle_v4i32_0145
259 ; ALL:         punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
260 ; ALL-NEXT:    retq
261   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
262   ret <4 x i32> %shuffle
263 }
264 define <4 x i32> @shuffle_v4i32_0451(<4 x i32> %a, <4 x i32> %b) {
265 ; ALL-LABEL: @shuffle_v4i32_0451
266 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
267 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2,3,1]
268 ; ALL-NEXT:    retq
269   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 5, i32 1>
270   ret <4 x i32> %shuffle
271 }
272 define <4 x i32> @shuffle_v4i32_4501(<4 x i32> %a, <4 x i32> %b) {
273 ; SSE2-LABEL: @shuffle_v4i32_4501
274 ; SSE2:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
275 ; SSE2-NEXT:    movdqa %xmm1, %xmm0
276 ; SSE2-NEXT:    retq
277 ;
278 ; SSE3-LABEL: @shuffle_v4i32_4501
279 ; SSE3:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
280 ; SSE3-NEXT:    movdqa %xmm1, %xmm0
281 ; SSE3-NEXT:    retq
282 ;
283 ; SSE41-LABEL: @shuffle_v4i32_4501
284 ; SSE41:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
285 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
286 ; SSE41-NEXT:    retq
287 ;
288 ; AVX1-LABEL: @shuffle_v4i32_4501
289 ; AVX1:         punpcklqdq {{.*}} # xmm0 = xmm1[0],xmm0[0]
290 ; AVX1-NEXT:    retq
291   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
292   ret <4 x i32> %shuffle
293 }
294 define <4 x i32> @shuffle_v4i32_4015(<4 x i32> %a, <4 x i32> %b) {
295 ; ALL-LABEL: @shuffle_v4i32_4015
296 ; ALL:         shufps {{.*}} # xmm0 = xmm0[0,1],xmm1[0,1]
297 ; ALL-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0,1,3]
298 ; ALL-NEXT:    retq
299   %shuffle = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 0, i32 1, i32 5>
300   ret <4 x i32> %shuffle
301 }
302
303 define <4 x float> @shuffle_v4f32_4zzz(<4 x float> %a) {
304 ; SSE2-LABEL: @shuffle_v4f32_4zzz
305 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
306 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
307 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
308 ; SSE2-NEXT:    retq
309 ;
310 ; SSE3-LABEL: @shuffle_v4f32_4zzz
311 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
312 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][1,0]
313 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,2],[[X]][2,3]
314 ; SSE3-NEXT:    retq
315 ;
316 ; SSE41-LABEL: @shuffle_v4f32_4zzz
317 ; SSE41:         xorps %[[X:xmm[0-9]+]], %[[X]]
318 ; SSE41-NEXT:    blendps {{.*}} # [[X]] = xmm0[0],[[X]][1,2,3]
319 ; SSE41-NEXT:    movaps %[[X]], %xmm0
320 ; SSE41-NEXT:    retq
321 ;
322 ; AVX1-LABEL: @shuffle_v4f32_4zzz
323 ; AVX1:         vxorps %[[X:xmm[0-9]+]], %[[X]]
324 ; AVX1-NEXT:    vblendps {{.*}} # xmm0 = xmm0[0],[[X]][1,2,3]
325 ; AVX1-NEXT:    retq
326   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
327   ret <4 x float> %shuffle
328 }
329
330 define <4 x float> @shuffle_v4f32_z4zz(<4 x float> %a) {
331 ; SSE2-LABEL: @shuffle_v4f32_z4zz
332 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
333 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
334 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
335 ; SSE2-NEXT:    retq
336 ;
337 ; SSE3-LABEL: @shuffle_v4f32_z4zz
338 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
339 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][2,0]
340 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][3,0]
341 ; SSE3-NEXT:    retq
342 ;
343 ; SSE41-LABEL: @shuffle_v4f32_z4zz
344 ; SSE41:         insertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
345 ; SSE41-NEXT:    retq
346 ;
347 ; AVX1-LABEL: @shuffle_v4f32_z4zz
348 ; AVX1:         vinsertps {{.*}} # xmm0 = zero,xmm0[0],zero,zero
349 ; AVX1-NEXT:    retq
350   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
351   ret <4 x float> %shuffle
352 }
353
354 define <4 x float> @shuffle_v4f32_zz4z(<4 x float> %a) {
355 ; SSE2-LABEL: @shuffle_v4f32_zz4z
356 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
357 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
358 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
359 ; SSE2-NEXT:    movaps %[[X]], %xmm0
360 ; SSE2-NEXT:    retq
361 ;
362 ; SSE3-LABEL: @shuffle_v4f32_zz4z
363 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
364 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[0,0],[[X]][0,0]
365 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,0],xmm0[0,2]
366 ; SSE3-NEXT:    movaps %[[X]], %xmm0
367 ; SSE3-NEXT:    retq
368 ;
369 ; SSE41-LABEL: @shuffle_v4f32_zz4z
370 ; SSE41:         insertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
371 ; SSE41-NEXT:    retq
372 ;
373 ; AVX1-LABEL: @shuffle_v4f32_zz4z
374 ; AVX1:         vinsertps {{.*}} # xmm0 = zero,zero,xmm0[0],zero
375 ; AVX1-NEXT:    retq
376   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
377   ret <4 x float> %shuffle
378 }
379
380 define <4 x float> @shuffle_v4f32_zuu4(<4 x float> %a) {
381 ; SSE2-LABEL: @shuffle_v4f32_zuu4
382 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
383 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
384 ; SSE2-NEXT:    movaps %[[X]], %xmm0
385 ; SSE2-NEXT:    retq
386 ;
387 ; SSE3-LABEL: @shuffle_v4f32_zuu4
388 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
389 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
390 ; SSE3-NEXT:    movaps %[[X]], %xmm0
391 ; SSE3-NEXT:    retq
392 ;
393 ; SSE41-LABEL: @shuffle_v4f32_zuu4
394 ; SSE41:         insertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
395 ; SSE41-NEXT:    retq
396 ;
397 ; AVX1-LABEL: @shuffle_v4f32_zuu4
398 ; AVX1:         vinsertps {{.*}} # xmm0 = zero,zero,zero,xmm0[0]
399 ; AVX1-NEXT:    retq
400   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
401   ret <4 x float> %shuffle
402 }
403
404 define <4 x float> @shuffle_v4f32_zzz7(<4 x float> %a) {
405 ; SSE2-LABEL: @shuffle_v4f32_zzz7
406 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
407 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
408 ; SSE2-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
409 ; SSE2-NEXT:    movaps %[[X]], %xmm0
410 ; SSE2-NEXT:    retq
411 ;
412 ; SSE3-LABEL: @shuffle_v4f32_zzz7
413 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
414 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[3,0],[[X]][2,0]
415 ; SSE3-NEXT:    shufps {{.*}} # [[X]] = [[X]][0,1],xmm0[2,0]
416 ; SSE3-NEXT:    movaps %[[X]], %xmm0
417 ; SSE3-NEXT:    retq
418 ;
419 ; SSE41-LABEL: @shuffle_v4f32_zzz7
420 ; SSE41:         xorps %[[X:xmm[0-9]+]], %[[X]]
421 ; SSE41-NEXT:    blendps {{.*}} # [[X]] = [[X]][0,1,2],xmm0[3]
422 ; SSE41-NEXT:    movaps %[[X]], %xmm0
423 ; SSE41-NEXT:    retq
424 ;
425 ; AVX1-LABEL: @shuffle_v4f32_zzz7
426 ; AVX1:         vxorps %[[X:xmm[0-9]+]], %[[X]]
427 ; AVX1-NEXT:    vblendps {{.*}} # xmm0 = [[X]][0,1,2],xmm0[3]
428 ; AVX1-NEXT:    retq
429   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
430   ret <4 x float> %shuffle
431 }
432
433 define <4 x float> @shuffle_v4f32_z6zz(<4 x float> %a) {
434 ; SSE2-LABEL: @shuffle_v4f32_z6zz
435 ; SSE2:         xorps %[[X:xmm[0-9]+]], %[[X]]
436 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
437 ; SSE2-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
438 ; SSE2-NEXT:    retq
439 ;
440 ; SSE3-LABEL: @shuffle_v4f32_z6zz
441 ; SSE3:         xorps %[[X:xmm[0-9]+]], %[[X]]
442 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][0,0]
443 ; SSE3-NEXT:    shufps {{.*}} # xmm0 = xmm0[2,0],[[X]][2,3]
444 ; SSE3-NEXT:    retq
445 ;
446 ; SSE41-LABEL: @shuffle_v4f32_z6zz
447 ; SSE41:         insertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
448 ; SSE41-NEXT:    retq
449 ;
450 ; AVX1-LABEL: @shuffle_v4f32_z6zz
451 ; AVX1:         vinsertps {{.*}} # xmm0 = zero,xmm0[2],zero,zero
452 ; AVX1-NEXT:    retq
453   %shuffle = shufflevector <4 x float> zeroinitializer, <4 x float> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
454   ret <4 x float> %shuffle
455 }
456
457 define <4 x i32> @shuffle_v4i32_4zzz(i32 %i) {
458 ; ALL-LABEL: @shuffle_v4i32_4zzz
459 ; ALL:         movd {{.*}}, %xmm0
460 ; ALL-NEXT:    retq
461   %a = insertelement <4 x i32> undef, i32 %i, i32 0
462   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 4, i32 1, i32 2, i32 3>
463   ret <4 x i32> %shuffle
464 }
465
466 define <4 x i32> @shuffle_v4i32_z4zz(i32 %i) {
467 ; ALL-LABEL: @shuffle_v4i32_z4zz
468 ; ALL:         movd {{.*}}, %xmm0
469 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
470 ; ALL-NEXT:    retq
471   %a = insertelement <4 x i32> undef, i32 %i, i32 0
472   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 2, i32 4, i32 3, i32 0>
473   ret <4 x i32> %shuffle
474 }
475
476 define <4 x i32> @shuffle_v4i32_zz4z(i32 %i) {
477 ; ALL-LABEL: @shuffle_v4i32_zz4z
478 ; ALL:         movd {{.*}}, %xmm0
479 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,1,0,1]
480 ; ALL-NEXT:    retq
481   %a = insertelement <4 x i32> undef, i32 %i, i32 0
482   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 0, i32 4, i32 0>
483   ret <4 x i32> %shuffle
484 }
485
486 define <4 x i32> @shuffle_v4i32_zuu4(i32 %i) {
487 ; ALL-LABEL: @shuffle_v4i32_zuu4
488 ; ALL:         movd {{.*}}, %xmm0
489 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,1,1,0]
490 ; ALL-NEXT:    retq
491   %a = insertelement <4 x i32> undef, i32 %i, i32 0
492   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 undef, i32 undef, i32 4>
493   ret <4 x i32> %shuffle
494 }
495
496 define <4 x i32> @shuffle_v4i32_z6zz(i32 %i) {
497 ; ALL-LABEL: @shuffle_v4i32_z6zz
498 ; ALL:         movd {{.*}}, %xmm0
499 ; ALL-NEXT:    pshufd {{.*}} # xmm0 = xmm0[1,0,1,1]
500 ; ALL-NEXT:    retq
501   %a = insertelement <4 x i32> undef, i32 %i, i32 2
502   %shuffle = shufflevector <4 x i32> zeroinitializer, <4 x i32> %a, <4 x i32> <i32 0, i32 6, i32 2, i32 3>
503   ret <4 x i32> %shuffle
504 }