3b3e7d8e1aec6720f9524d5e7a458d7b8358c869
[oota-llvm.git] / test / CodeGen / X86 / vector-shuffle-sse4a.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+ssse3,+sse4a | FileCheck %s --check-prefix=ALL --check-prefix=BTVER1
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx,+sse4a | FileCheck %s --check-prefix=ALL --check-prefix=BTVER2
3
4 ;
5 ; EXTRQI
6 ;
7
8 define <16 x i8> @shuf_0zzzuuuuuuuuuuuu(<16 x i8> %a0) {
9 ; BTVER1-LABEL: shuf_0zzzuuuuuuuuuuuu:
10 ; BTVER1:       # BB#0:
11 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
12 ; BTVER1-NEXT:    retq
13 ;
14 ; BTVER2-LABEL: shuf_0zzzuuuuuuuuuuuu:
15 ; BTVER2:       # BB#0:
16 ; BTVER2-NEXT:    vpmovzxbq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero
17 ; BTVER2-NEXT:    retq
18   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 0, i32 16, i32 16, i32 16, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
19   ret <16 x i8> %s
20 }
21
22 define <16 x i8> @shuf_0zzzzzzz1zzzzzzz(<16 x i8> %a0) {
23 ; BTVER1-LABEL: shuf_0zzzzzzz1zzzzzzz:
24 ; BTVER1:       # BB#0:
25 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
26 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[1],zero,zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
27 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
28 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
29 ; BTVER1-NEXT:    retq
30 ;
31 ; BTVER2-LABEL: shuf_0zzzzzzz1zzzzzzz:
32 ; BTVER2:       # BB#0:
33 ; BTVER2-NEXT:    vpmovzxbq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero
34 ; BTVER2-NEXT:    retq
35   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 0, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 1, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
36   ret <16 x i8> %s
37 }
38
39 define <16 x i8> @shuf_2zzzzzzz3zzzzzzz(<16 x i8> %a0) {
40 ; BTVER1-LABEL: shuf_2zzzzzzz3zzzzzzz:
41 ; BTVER1:       # BB#0:
42 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
43 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[3],zero,zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
44 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[2],zero,zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
45 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
46 ; BTVER1-NEXT:    retq
47 ;
48 ; BTVER2-LABEL: shuf_2zzzzzzz3zzzzzzz:
49 ; BTVER2:       # BB#0:
50 ; BTVER2-NEXT:    vpsrld $16, %xmm0, %xmm0
51 ; BTVER2-NEXT:    vpmovzxbq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,zero,zero,zero,zero,xmm0[1],zero,zero,zero,zero,zero,zero,zero
52 ; BTVER2-NEXT:    retq
53   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 2, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 3, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
54   ret <16 x i8> %s
55 }
56
57 define <16 x i8> @shuf_01zzuuuuuuuuuuuu(<16 x i8> %a0) {
58 ; BTVER1-LABEL: shuf_01zzuuuuuuuuuuuu:
59 ; BTVER1:       # BB#0:
60 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
61 ; BTVER1-NEXT:    retq
62 ;
63 ; BTVER2-LABEL: shuf_01zzuuuuuuuuuuuu:
64 ; BTVER2:       # BB#0:
65 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
66 ; BTVER2-NEXT:    retq
67   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 0, i32 1, i32 16, i32 16, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
68   ret <16 x i8> %s
69 }
70
71 define <16 x i8> @shuf_01zzzzzz23zzzzzz(<16 x i8> %a0) {
72 ; BTVER1-LABEL: shuf_01zzzzzz23zzzzzz:
73 ; BTVER1:       # BB#0:
74 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
75 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[2,3],zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
76 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
77 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
78 ; BTVER1-NEXT:    retq
79 ;
80 ; BTVER2-LABEL: shuf_01zzzzzz23zzzzzz:
81 ; BTVER2:       # BB#0:
82 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
83 ; BTVER2-NEXT:    retq
84   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 0, i32 1, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 2, i32 3, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
85   ret <16 x i8> %s
86 }
87
88 define <16 x i8> @shuf_1zzzuuuuuuuuuuuu(<16 x i8> %a0) {
89 ; ALL-LABEL: shuf_1zzzuuuuuuuuuuuu:
90 ; ALL:       # BB#0:
91 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[1],zero,zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
92 ; ALL-NEXT:    retq
93   %s = shufflevector <16 x i8> %a0, <16 x i8> zeroinitializer, <16 x i32> <i32 1, i32 16, i32 16, i32 16, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
94   ret <16 x i8> %s
95 }
96
97 define <8 x i16> @shuf_1zzzuuuu(<8 x i16> %a0) {
98 ; ALL-LABEL: shuf_1zzzuuuu:
99 ; ALL:       # BB#0:
100 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[2,3],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
101 ; ALL-NEXT:    retq
102   %s = shufflevector <8 x i16> %a0, <8 x i16> zeroinitializer, <8 x i32> <i32 1, i32 8, i32 8, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
103   ret <8 x i16> %s
104 }
105
106 define <8 x i16> @shuf_12zzuuuu(<8 x i16> %a0) {
107 ; ALL-LABEL: shuf_12zzuuuu:
108 ; ALL:       # BB#0:
109 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[2,3,4,5],zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
110 ; ALL-NEXT:    retq
111   %s = shufflevector <8 x i16> %a0, <8 x i16> zeroinitializer, <8 x i32> <i32 1, i32 2, i32 8, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
112   ret <8 x i16> %s
113 }
114
115 define <8 x i16> @shuf_012zuuuu(<8 x i16> %a0) {
116 ; ALL-LABEL: shuf_012zuuuu:
117 ; ALL:       # BB#0:
118 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],zero,zero,xmm0[u,u,u,u,u,u,u,u]
119 ; ALL-NEXT:    retq
120   %s = shufflevector <8 x i16> %a0, <8 x i16> zeroinitializer, <8 x i32> <i32 0, i32 1, i32 2, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
121   ret <8 x i16> %s
122 }
123
124 define <8 x i16> @shuf_0zzz1zzz(<8 x i16> %a0) {
125 ; BTVER1-LABEL: shuf_0zzz1zzz:
126 ; BTVER1:       # BB#0:
127 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
128 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[2,3],zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
129 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
130 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
131 ; BTVER1-NEXT:    retq
132 ;
133 ; BTVER2-LABEL: shuf_0zzz1zzz:
134 ; BTVER2:       # BB#0:
135 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
136 ; BTVER2-NEXT:    retq
137   %s = shufflevector <8 x i16> %a0, <8 x i16> zeroinitializer, <8 x i32> <i32 0, i32 8, i32 8, i32 8, i32 1, i32 8, i32 8, i32 8>
138   ret <8 x i16> %s
139 }
140
141 define <4 x i32> @shuf_0z1z(<4 x i32> %a0) {
142 ; BTVER1-LABEL: shuf_0z1z:
143 ; BTVER1:       # BB#0:
144 ; BTVER1-NEXT:    pxor %xmm1, %xmm1
145 ; BTVER1-NEXT:    punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
146 ; BTVER1-NEXT:    retq
147 ;
148 ; BTVER2-LABEL: shuf_0z1z:
149 ; BTVER2:       # BB#0:
150 ; BTVER2-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm0[0],zero,xmm0[1],zero
151 ; BTVER2-NEXT:    retq
152   %s = shufflevector <4 x i32> %a0, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 1, i32 4>
153   ret <4 x i32> %s
154 }
155
156 ;
157 ; INSERTQI
158 ;
159
160 define <16 x i8> @shuf_0_0_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
161 ; ALL-LABEL: shuf_0_0_2_3_uuuu_uuuu_uuuu:
162 ; ALL:       # BB#0:
163 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,0,2,3,4,5,6,7,u,u,u,u,u,u,u,u]
164 ; ALL-NEXT:    retq
165   %s = shufflevector <16 x i8> %a0, <16 x i8> %a1, <16 x i32> <i32 0, i32 0, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
166   ret <16 x i8> %s
167 }
168
169 define <16 x i8> @shuf_0_16_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
170 ; ALL-LABEL: shuf_0_16_2_3_uuuu_uuuu_uuuu:
171 ; ALL:       # BB#0:
172 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[2,3,4,5,6,7,u,u,u,u,u,u,u,u]
173 ; ALL-NEXT:    retq
174   %s = shufflevector <16 x i8> %a0, <16 x i8> %a1, <16 x i32> <i32 0, i32 16, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
175   ret <16 x i8> %s
176 }
177
178 define <16 x i8> @shuf_16_1_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
179 ; ALL-LABEL: shuf_16_1_2_3_uuuu_uuuu_uuuu:
180 ; ALL:       # BB#0:
181 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3,4,5,6,7,u,u,u,u,u,u,u,u]
182 ; ALL-NEXT:    retq
183   %s = shufflevector <16 x i8> %a0, <16 x i8> %a1, <16 x i32> <i32 16, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
184   ret <16 x i8> %s
185 }
186
187 define <8 x i16> @shuf_0823uuuu(<8 x i16> %a0, <8 x i16> %a1) {
188 ; ALL-LABEL: shuf_0823uuuu:
189 ; ALL:       # BB#0:
190 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1],xmm0[4,5,6,7,u,u,u,u,u,u,u,u]
191 ; ALL-NEXT:    retq
192   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 8, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
193   ret <8 x i16> %s
194 }
195
196 define <8 x i16> @shuf_0183uuuu(<8 x i16> %a0, <8 x i16> %a1) {
197 ; ALL-LABEL: shuf_0183uuuu:
198 ; ALL:       # BB#0:
199 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[0,1],xmm0[6,7,u,u,u,u,u,u,u,u]
200 ; ALL-NEXT:    retq
201   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 1, i32 8, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
202   ret <8 x i16> %s
203 }
204
205 define <8 x i16> @shuf_0128uuuu(<8 x i16> %a0, <8 x i16> %a1) {
206 ; ALL-LABEL: shuf_0128uuuu:
207 ; ALL:       # BB#0:
208 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],xmm1[0,1],xmm0[u,u,u,u,u,u,u,u]
209 ; ALL-NEXT:    retq
210   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
211   ret <8 x i16> %s
212 }
213
214 define <8 x i16> @shuf_0893uuuu(<8 x i16> %a0, <8 x i16> %a1) {
215 ; ALL-LABEL: shuf_0893uuuu:
216 ; ALL:       # BB#0:
217 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1,2,3],xmm0[6,7,u,u,u,u,u,u,u,u]
218 ; ALL-NEXT:    retq
219   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 8, i32 9, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
220   ret <8 x i16> %s
221 }
222
223 define <8 x i16> @shuf_089Auuuu(<8 x i16> %a0, <8 x i16> %a1) {
224 ; ALL-LABEL: shuf_089Auuuu:
225 ; ALL:       # BB#0:
226 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1,2,3,4,5],xmm0[u,u,u,u,u,u,u,u]
227 ; ALL-NEXT:    retq
228   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 8, i32 9, i32 10, i32 undef, i32 undef, i32 undef, i32 undef>
229   ret <8 x i16> %s
230 }
231
232 define <8 x i16> @shuf_089uuuuu(<8 x i16> %a0, <8 x i16> %a1) {
233 ; ALL-LABEL: shuf_089uuuuu:
234 ; ALL:       # BB#0:
235 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1,2,3],xmm0[6,7,u,u,u,u,u,u,u,u]
236 ; ALL-NEXT:    retq
237   %s = shufflevector <8 x i16> %a0, <8 x i16> %a1, <8 x i32> <i32 0, i32 8, i32 9, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
238   ret <8 x i16> %s
239 }