[x86] Generalize the single-element insertion lowering to work with
[oota-llvm.git] / test / CodeGen / X86 / vector-shuffle-128-v2.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=+ssse3 -x86-experimental-vector-shuffle-lowering | FileCheck %s --check-prefix=ALL --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=SSE41
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 <2 x i64> @shuffle_v2i64_00(<2 x i64> %a, <2 x i64> %b) {
10 ; ALL-LABEL: @shuffle_v2i64_00
11 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[0,1,0,1]
12 ; ALL-NEXT:    retq
13   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 0>
14   ret <2 x i64> %shuffle
15 }
16 define <2 x i64> @shuffle_v2i64_10(<2 x i64> %a, <2 x i64> %b) {
17 ; ALL-LABEL: @shuffle_v2i64_10
18 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[2,3,0,1]
19 ; ALL-NEXT:    retq
20   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 0>
21   ret <2 x i64> %shuffle
22 }
23 define <2 x i64> @shuffle_v2i64_11(<2 x i64> %a, <2 x i64> %b) {
24 ; ALL-LABEL: @shuffle_v2i64_11
25 ; ALL:         pshufd {{.*}} # xmm0 = xmm0[2,3,2,3]
26 ; ALL-NEXT:    retq
27   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 1>
28   ret <2 x i64> %shuffle
29 }
30 define <2 x i64> @shuffle_v2i64_22(<2 x i64> %a, <2 x i64> %b) {
31 ; ALL-LABEL: @shuffle_v2i64_22
32 ; ALL:         pshufd {{.*}} # xmm0 = xmm1[0,1,0,1]
33 ; ALL-NEXT:    retq
34   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 2>
35   ret <2 x i64> %shuffle
36 }
37 define <2 x i64> @shuffle_v2i64_32(<2 x i64> %a, <2 x i64> %b) {
38 ; ALL-LABEL: @shuffle_v2i64_32
39 ; ALL:         pshufd {{.*}} # xmm0 = xmm1[2,3,0,1]
40 ; ALL-NEXT:    retq
41   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 2>
42   ret <2 x i64> %shuffle
43 }
44 define <2 x i64> @shuffle_v2i64_33(<2 x i64> %a, <2 x i64> %b) {
45 ; ALL-LABEL: @shuffle_v2i64_33
46 ; ALL:         pshufd {{.*}} # xmm0 = xmm1[2,3,2,3]
47 ; ALL-NEXT:    retq
48   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 3>
49   ret <2 x i64> %shuffle
50 }
51
52 define <2 x double> @shuffle_v2f64_00(<2 x double> %a, <2 x double> %b) {
53 ; SSE2-LABEL: @shuffle_v2f64_00
54 ; SSE2:         movlhps {{.*}} # xmm0 = xmm0[0,0]
55 ; SSE2-NEXT:    retq
56 ;
57 ; SSE3-LABEL: @shuffle_v2f64_00
58 ; SSE3:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
59 ; SSE3-NEXT:    retq
60 ;
61 ; SSSE3-LABEL: @shuffle_v2f64_00
62 ; SSSE3:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
63 ; SSSE3-NEXT:    retq
64 ;
65 ; SSE41-LABEL: @shuffle_v2f64_00
66 ; SSE41:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
67 ; SSE41-NEXT:    retq
68   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 0, i32 0>
69   ret <2 x double> %shuffle
70 }
71 define <2 x double> @shuffle_v2f64_10(<2 x double> %a, <2 x double> %b) {
72 ; ALL-LABEL: @shuffle_v2f64_10
73 ; ALL:         shufpd {{.*}} # xmm0 = xmm0[1,0]
74 ; ALL-NEXT:    retq
75   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 1, i32 0>
76   ret <2 x double> %shuffle
77 }
78 define <2 x double> @shuffle_v2f64_11(<2 x double> %a, <2 x double> %b) {
79 ; ALL-LABEL: @shuffle_v2f64_11
80 ; ALL:         movhlps {{.*}} # xmm0 = xmm0[1,1]
81 ; ALL-NEXT:    retq
82   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 1, i32 1>
83   ret <2 x double> %shuffle
84 }
85 define <2 x double> @shuffle_v2f64_22(<2 x double> %a, <2 x double> %b) {
86 ; SSE2-LABEL: @shuffle_v2f64_22
87 ; SSE2:         movlhps {{.*}} # xmm1 = xmm1[0,0]
88 ; SSE2-NEXT:    movaps %xmm1, %xmm0
89 ; SSE2-NEXT:    retq
90 ;
91 ; SSE3-LABEL: @shuffle_v2f64_22
92 ; SSE3:         unpcklpd {{.*}} # xmm1 = xmm1[0,0]
93 ; SSE3-NEXT:    movapd %xmm1, %xmm0
94 ; SSE3-NEXT:    retq
95 ;
96 ; SSSE3-LABEL: @shuffle_v2f64_22
97 ; SSSE3:         unpcklpd {{.*}} # xmm1 = xmm1[0,0]
98 ; SSSE3-NEXT:    movapd %xmm1, %xmm0
99 ; SSSE3-NEXT:    retq
100 ;
101 ; SSE41-LABEL: @shuffle_v2f64_22
102 ; SSE41:         unpcklpd {{.*}} # xmm1 = xmm1[0,0]
103 ; SSE41-NEXT:    movapd %xmm1, %xmm0
104 ; SSE41-NEXT:    retq
105   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 2, i32 2>
106   ret <2 x double> %shuffle
107 }
108 define <2 x double> @shuffle_v2f64_32(<2 x double> %a, <2 x double> %b) {
109 ; ALL-LABEL: @shuffle_v2f64_32
110 ; ALL:         pshufd {{.*}} # xmm0 = xmm1[2,3,0,1]
111 ; ALL-NEXT:    retq
112   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 3, i32 2>
113   ret <2 x double> %shuffle
114 }
115 define <2 x double> @shuffle_v2f64_33(<2 x double> %a, <2 x double> %b) {
116 ; ALL-LABEL: @shuffle_v2f64_33
117 ; ALL:         movhlps {{.*}} # xmm1 = xmm1[1,1]
118 ; ALL-NEXT:    movaps %xmm1, %xmm0
119 ; ALL-NEXT:    retq
120   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 3, i32 3>
121   ret <2 x double> %shuffle
122 }
123 define <2 x double> @shuffle_v2f64_03(<2 x double> %a, <2 x double> %b) {
124 ; SSE2-LABEL: @shuffle_v2f64_03
125 ; SSE2:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
126 ; SSE2-NEXT:    retq
127 ;
128 ; SSE3-LABEL: @shuffle_v2f64_03
129 ; SSE3:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
130 ; SSE3-NEXT:    retq
131 ;
132 ; SSSE3-LABEL: @shuffle_v2f64_03
133 ; SSSE3:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
134 ; SSSE3-NEXT:    retq
135 ;
136 ; SSE41-LABEL: @shuffle_v2f64_03
137 ; SSE41:         blendpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
138 ; SSE41-NEXT:    retq
139   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 0, i32 3>
140   ret <2 x double> %shuffle
141 }
142 define <2 x double> @shuffle_v2f64_21(<2 x double> %a, <2 x double> %b) {
143 ; SSE2-LABEL: @shuffle_v2f64_21
144 ; SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
145 ; SSE2-NEXT:    movapd %xmm1, %xmm0
146 ; SSE2-NEXT:    retq
147 ;
148 ; SSE3-LABEL: @shuffle_v2f64_21
149 ; SSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
150 ; SSE3-NEXT:    movapd %xmm1, %xmm0
151 ; SSE3-NEXT:    retq
152 ;
153 ; SSSE3-LABEL: @shuffle_v2f64_21
154 ; SSSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
155 ; SSSE3-NEXT:    movapd %xmm1, %xmm0
156 ; SSSE3-NEXT:    retq
157 ;
158 ; SSE41-LABEL: @shuffle_v2f64_21
159 ; SSE41:         blendpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
160 ; SSE41-NEXT:    movapd %xmm1, %xmm0
161 ; SSE41-NEXT:    retq
162   %shuffle = shufflevector <2 x double> %a, <2 x double> %b, <2 x i32> <i32 2, i32 1>
163   ret <2 x double> %shuffle
164 }
165
166
167 define <2 x i64> @shuffle_v2i64_02(<2 x i64> %a, <2 x i64> %b) {
168 ; ALL-LABEL: @shuffle_v2i64_02
169 ; ALL:         punpcklqdq {{.*}} # xmm0 = xmm0[0],xmm1[0]
170 ; ALL-NEXT:    retq
171   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 2>
172   ret <2 x i64> %shuffle
173 }
174 define <2 x i64> @shuffle_v2i64_02_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
175 ; ALL-LABEL: @shuffle_v2i64_02_copy
176 ; ALL:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm2[0]
177 ; ALL-NEXT:    movdqa %xmm1, %xmm0
178 ; ALL-NEXT:    retq
179   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 2>
180   ret <2 x i64> %shuffle
181 }
182 define <2 x i64> @shuffle_v2i64_03(<2 x i64> %a, <2 x i64> %b) {
183 ; SSE2-LABEL: @shuffle_v2i64_03
184 ; SSE2:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
185 ; SSE2-NEXT:    retq
186 ;
187 ; SSE3-LABEL: @shuffle_v2i64_03
188 ; SSE3:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
189 ; SSE3-NEXT:    retq
190 ;
191 ; SSSE3-LABEL: @shuffle_v2i64_03
192 ; SSSE3:         shufpd {{.*}} # xmm0 = xmm0[0],xmm1[1]
193 ; SSSE3-NEXT:    retq
194 ;
195 ; SSE41-LABEL: @shuffle_v2i64_03
196 ; SSE41:         pblendw {{.*}} # xmm0 = xmm0[0,1,2,3],xmm1[4,5,6,7]
197 ; SSE41-NEXT:    retq
198   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 3>
199   ret <2 x i64> %shuffle
200 }
201 define <2 x i64> @shuffle_v2i64_03_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
202 ; SSE2-LABEL: @shuffle_v2i64_03_copy
203 ; SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm2[1]
204 ; SSE2-NEXT:    movapd %xmm1, %xmm0
205 ; SSE2-NEXT:    retq
206 ;
207 ; SSE3-LABEL: @shuffle_v2i64_03_copy
208 ; SSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm2[1]
209 ; SSE3-NEXT:    movapd %xmm1, %xmm0
210 ; SSE3-NEXT:    retq
211 ;
212 ; SSSE3-LABEL: @shuffle_v2i64_03_copy
213 ; SSSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm2[1]
214 ; SSSE3-NEXT:    movapd %xmm1, %xmm0
215 ; SSSE3-NEXT:    retq
216 ;
217 ; SSE41-LABEL: @shuffle_v2i64_03_copy
218 ; SSE41:         pblendw {{.*}} # xmm1 = xmm1[0,1,2,3],xmm2[4,5,6,7]
219 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
220 ; SSE41-NEXT:    retq
221   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 0, i32 3>
222   ret <2 x i64> %shuffle
223 }
224 define <2 x i64> @shuffle_v2i64_12(<2 x i64> %a, <2 x i64> %b) {
225 ; SSE2-LABEL: @shuffle_v2i64_12
226 ; SSE2:         shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
227 ; SSE2-NEXT:    retq
228 ;
229 ; SSE3-LABEL: @shuffle_v2i64_12
230 ; SSE3:         shufpd {{.*}} # xmm0 = xmm0[1],xmm1[0]
231 ; SSE3-NEXT:    retq
232 ;
233 ; SSSE3-LABEL: @shuffle_v2i64_12
234 ; SSSE3:         palignr {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
235 ; SSSE3-NEXT:    movdqa %xmm1, %xmm0
236 ; SSSE3-NEXT:    retq
237 ;
238 ; SSE41-LABEL: @shuffle_v2i64_12
239 ; SSE41:         palignr {{.*}} # xmm1 = xmm0[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
240 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
241 ; SSE41-NEXT:    retq
242   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 2>
243   ret <2 x i64> %shuffle
244 }
245 define <2 x i64> @shuffle_v2i64_12_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
246 ; SSE2-LABEL: @shuffle_v2i64_12_copy
247 ; SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm2[0]
248 ; SSE2-NEXT:    movapd %xmm1, %xmm0
249 ; SSE2-NEXT:    retq
250 ;
251 ; SSE3-LABEL: @shuffle_v2i64_12_copy
252 ; SSE3:         shufpd {{.*}} # xmm1 = xmm1[1],xmm2[0]
253 ; SSE3-NEXT:    movapd %xmm1, %xmm0
254 ; SSE3-NEXT:    retq
255 ;
256 ; SSSE3-LABEL: @shuffle_v2i64_12_copy
257 ; SSSE3:         palignr {{.*}} # xmm2 = xmm1[8,9,10,11,12,13,14,15],xmm2[0,1,2,3,4,5,6,7]
258 ; SSSE3-NEXT:    movdqa %xmm2, %xmm0
259 ; SSSE3-NEXT:    retq
260 ;
261 ; SSE41-LABEL: @shuffle_v2i64_12_copy
262 ; SSE41:         palignr {{.*}} # xmm2 = xmm1[8,9,10,11,12,13,14,15],xmm2[0,1,2,3,4,5,6,7]
263 ; SSE41-NEXT:    movdqa %xmm2, %xmm0
264 ; SSE41-NEXT:    retq
265   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 2>
266   ret <2 x i64> %shuffle
267 }
268 define <2 x i64> @shuffle_v2i64_13(<2 x i64> %a, <2 x i64> %b) {
269 ; ALL-LABEL: @shuffle_v2i64_13
270 ; ALL:         punpckhqdq {{.*}} # xmm0 = xmm0[1],xmm1[1]
271 ; ALL-NEXT:    retq
272   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 3>
273   ret <2 x i64> %shuffle
274 }
275 define <2 x i64> @shuffle_v2i64_13_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
276 ; ALL-LABEL: @shuffle_v2i64_13_copy
277 ; ALL:         punpckhqdq {{.*}} # xmm1 = xmm1[1],xmm2[1]
278 ; ALL-NEXT:    movdqa %xmm1, %xmm0
279 ; ALL-NEXT:    retq
280   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 1, i32 3>
281   ret <2 x i64> %shuffle
282 }
283 define <2 x i64> @shuffle_v2i64_20(<2 x i64> %a, <2 x i64> %b) {
284 ; ALL-LABEL: @shuffle_v2i64_20
285 ; ALL:         punpcklqdq {{.*}} # xmm1 = xmm1[0],xmm0[0]
286 ; ALL-NEXT:    movdqa %xmm1, %xmm0
287 ; ALL-NEXT:    retq
288   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 0>
289   ret <2 x i64> %shuffle
290 }
291 define <2 x i64> @shuffle_v2i64_20_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
292 ; ALL-LABEL: @shuffle_v2i64_20_copy
293 ; ALL:         punpcklqdq {{.*}} # xmm2 = xmm2[0],xmm1[0]
294 ; ALL-NEXT:    movdqa %xmm2, %xmm0
295 ; ALL-NEXT:    retq
296   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 0>
297   ret <2 x i64> %shuffle
298 }
299 define <2 x i64> @shuffle_v2i64_21(<2 x i64> %a, <2 x i64> %b) {
300 ; SSE2-LABEL: @shuffle_v2i64_21
301 ; SSE2:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
302 ; SSE2-NEXT:    movapd %xmm1, %xmm0
303 ; SSE2-NEXT:    retq
304 ;
305 ; SSE3-LABEL: @shuffle_v2i64_21
306 ; SSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
307 ; SSE3-NEXT:    movapd %xmm1, %xmm0
308 ; SSE3-NEXT:    retq
309 ;
310 ; SSSE3-LABEL: @shuffle_v2i64_21
311 ; SSSE3:         shufpd {{.*}} # xmm1 = xmm1[0],xmm0[1]
312 ; SSSE3-NEXT:    movapd %xmm1, %xmm0
313 ; SSSE3-NEXT:    retq
314 ;
315 ; SSE41-LABEL: @shuffle_v2i64_21
316 ; SSE41:         pblendw {{.*}} # xmm1 = xmm1[0,1,2,3],xmm0[4,5,6,7]
317 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
318 ; SSE41-NEXT:    retq
319   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 1>
320   ret <2 x i64> %shuffle
321 }
322 define <2 x i64> @shuffle_v2i64_21_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
323 ; SSE2-LABEL: @shuffle_v2i64_21_copy
324 ; SSE2:         shufpd {{.*}} # xmm2 = xmm2[0],xmm1[1]
325 ; SSE2-NEXT:    movapd %xmm2, %xmm0
326 ; SSE2-NEXT:    retq
327 ;
328 ; SSE3-LABEL: @shuffle_v2i64_21_copy
329 ; SSE3:         shufpd {{.*}} # xmm2 = xmm2[0],xmm1[1]
330 ; SSE3-NEXT:    movapd %xmm2, %xmm0
331 ; SSE3-NEXT:    retq
332 ;
333 ; SSSE3-LABEL: @shuffle_v2i64_21_copy
334 ; SSSE3:         shufpd {{.*}} # xmm2 = xmm2[0],xmm1[1]
335 ; SSSE3-NEXT:    movapd %xmm2, %xmm0
336 ; SSSE3-NEXT:    retq
337 ;
338 ; SSE41-LABEL: @shuffle_v2i64_21_copy
339 ; SSE41:         pblendw {{.*}} # xmm2 = xmm2[0,1,2,3],xmm1[4,5,6,7]
340 ; SSE41-NEXT:    movdqa %xmm2, %xmm0
341 ; SSE41-NEXT:    retq
342   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 2, i32 1>
343   ret <2 x i64> %shuffle
344 }
345 define <2 x i64> @shuffle_v2i64_30(<2 x i64> %a, <2 x i64> %b) {
346 ; SSE2-LABEL: @shuffle_v2i64_30
347 ; SSE2:         shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
348 ; SSE2-NEXT:    movapd %xmm1, %xmm0
349 ; SSE2-NEXT:    retq
350 ;
351 ; SSE3-LABEL: @shuffle_v2i64_30
352 ; SSE3:         shufpd {{.*}} # xmm1 = xmm1[1],xmm0[0]
353 ; SSE3-NEXT:    movapd %xmm1, %xmm0
354 ; SSE3-NEXT:    retq
355 ;
356 ; SSSE3-LABEL: @shuffle_v2i64_30
357 ; SSSE3:         palignr {{.*}} # xmm0 = xmm1[8,9,10,11,12,13,14,15],xmm0[0,1,2,3,4,5,6,7]
358 ; SSSE3-NEXT:    retq
359   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 0>
360   ret <2 x i64> %shuffle
361 }
362 define <2 x i64> @shuffle_v2i64_30_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
363 ; SSE2-LABEL: @shuffle_v2i64_30_copy
364 ; SSE2:         shufpd {{.*}} # xmm2 = xmm2[1],xmm1[0]
365 ; SSE2-NEXT:    movapd %xmm2, %xmm0
366 ; SSE2-NEXT:    retq
367 ;
368 ; SSE3-LABEL: @shuffle_v2i64_30_copy
369 ; SSE3:         shufpd {{.*}} # xmm2 = xmm2[1],xmm1[0]
370 ; SSE3-NEXT:    movapd %xmm2, %xmm0
371 ; SSE3-NEXT:    retq
372 ;
373 ; SSSE3-LABEL: @shuffle_v2i64_30_copy
374 ; SSSE3:         palignr {{.*}} # xmm1 = xmm2[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
375 ; SSSE3-NEXT:    movdqa %xmm1, %xmm0
376 ; SSSE3-NEXT:    retq
377 ;
378 ; SSE41-LABEL: @shuffle_v2i64_30_copy
379 ; SSE41:         palignr {{.*}} # xmm1 = xmm2[8,9,10,11,12,13,14,15],xmm1[0,1,2,3,4,5,6,7]
380 ; SSE41-NEXT:    movdqa %xmm1, %xmm0
381 ; SSE41-NEXT:    retq
382   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 0>
383   ret <2 x i64> %shuffle
384 }
385 define <2 x i64> @shuffle_v2i64_31(<2 x i64> %a, <2 x i64> %b) {
386 ; ALL-LABEL: @shuffle_v2i64_31
387 ; ALL:         punpckhqdq {{.*}} # xmm1 = xmm1[1],xmm0[1]
388 ; ALL-NEXT:    movdqa %xmm1, %xmm0
389 ; ALL-NEXT:    retq
390   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 1>
391   ret <2 x i64> %shuffle
392 }
393 define <2 x i64> @shuffle_v2i64_31_copy(<2 x i64> %nonce, <2 x i64> %a, <2 x i64> %b) {
394 ; ALL-LABEL: @shuffle_v2i64_31_copy
395 ; ALL:         punpckhqdq {{.*}} # xmm2 = xmm2[1],xmm1[1]
396 ; ALL-NEXT:    movdqa %xmm2, %xmm0
397 ; ALL-NEXT:    retq
398   %shuffle = shufflevector <2 x i64> %a, <2 x i64> %b, <2 x i32> <i32 3, i32 1>
399   ret <2 x i64> %shuffle
400 }
401
402
403 define <2 x i64> @insert_reg_and_zero_v2i64(i64 %a) {
404 ; ALL-LABEL: @insert_reg_and_zero_v2i64
405 ; ALL:         movd %rdi, %xmm0
406 ; ALL-NEXT:    retq
407   %v = insertelement <2 x i64> undef, i64 %a, i32 0
408   %shuffle = shufflevector <2 x i64> %v, <2 x i64> zeroinitializer, <2 x i32> <i32 0, i32 3>
409   ret <2 x i64> %shuffle
410 }
411
412 define <2 x i64> @insert_mem_and_zero_v2i64(i64* %ptr) {
413 ; ALL-LABEL: @insert_mem_and_zero_v2i64
414 ; ALL:         movq (%rdi), %xmm0
415 ; ALL-NEXT:    retq
416   %a = load i64* %ptr
417   %v = insertelement <2 x i64> undef, i64 %a, i32 0
418   %shuffle = shufflevector <2 x i64> %v, <2 x i64> zeroinitializer, <2 x i32> <i32 0, i32 3>
419   ret <2 x i64> %shuffle
420 }
421
422 define <2 x double> @insert_reg_and_zero_v2f64(double %a) {
423 ; ALL-LABEL: @insert_reg_and_zero_v2f64
424 ; ALL:         movq %xmm0, %xmm0
425 ; ALL-NEXT:    retq
426   %v = insertelement <2 x double> undef, double %a, i32 0
427   %shuffle = shufflevector <2 x double> %v, <2 x double> zeroinitializer, <2 x i32> <i32 0, i32 3>
428   ret <2 x double> %shuffle
429 }
430
431 define <2 x double> @insert_mem_and_zero_v2f64(double* %ptr) {
432 ; ALL-LABEL: @insert_mem_and_zero_v2f64
433 ; ALL:         movsd (%rdi), %xmm0
434 ; ALL-NEXT:    retq
435   %a = load double* %ptr
436   %v = insertelement <2 x double> undef, double %a, i32 0
437   %shuffle = shufflevector <2 x double> %v, <2 x double> zeroinitializer, <2 x i32> <i32 0, i32 3>
438   ret <2 x double> %shuffle
439 }
440
441 define <2 x double> @insert_dup_reg_v2f64(double %a) {
442 ; SSE2-LABEL: @insert_dup_reg_v2f64
443 ; SSE2:         movlhps {{.*}} # xmm0 = xmm0[0,0]
444 ; SSE2-NEXT:    retq
445 ;
446 ; FIXME: This should match movddup as well!
447 ; SSE3-LABEL: @insert_dup_reg_v2f64
448 ; SSE3:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
449 ; SSE3-NEXT:    retq
450 ;
451 ; FIXME: This should match movddup as well!
452 ; SSSE3-LABEL: @insert_dup_reg_v2f64
453 ; SSSE3:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
454 ; SSSE3-NEXT:    retq
455 ;
456 ; FIXME: This should match movddup as well!
457 ; SSE41-LABEL: @insert_dup_reg_v2f64
458 ; SSE41:         unpcklpd {{.*}} # xmm0 = xmm0[0,0]
459 ; SSE41-NEXT:    retq
460   %v = insertelement <2 x double> undef, double %a, i32 0
461   %shuffle = shufflevector <2 x double> %v, <2 x double> undef, <2 x i32> <i32 0, i32 0>
462   ret <2 x double> %shuffle
463 }
464 define <2 x double> @insert_dup_mem_v2f64(double* %ptr) {
465 ; SSE2-LABEL: @insert_dup_mem_v2f64
466 ; SSE2:         movsd {{.*}}, %xmm0
467 ; SSE2-NEXT:    movlhps {{.*}} # xmm0 = xmm0[0,0]
468 ; SSE2-NEXT:    retq
469 ;
470 ; SSE3-LABEL: @insert_dup_mem_v2f64
471 ; SSE3:         movddup {{.*}}, %xmm0
472 ; SSE3-NEXT:    retq
473 ;
474 ; SSSE3-LABEL: @insert_dup_mem_v2f64
475 ; SSSE3:         movddup {{.*}}, %xmm0
476 ; SSSE3-NEXT:    retq
477 ;
478 ; SSE41-LABEL: @insert_dup_mem_v2f64
479 ; SSE41:         movddup {{.*}}, %xmm0
480 ; SSE41-NEXT:    retq
481   %a = load double* %ptr
482   %v = insertelement <2 x double> undef, double %a, i32 0
483   %shuffle = shufflevector <2 x double> %v, <2 x double> undef, <2 x i32> <i32 0, i32 0>
484   ret <2 x double> %shuffle
485 }