AVX512: Implemented encoding and intrinsics for vpalignr
[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_01zzuuuuuuuuuuuu(<16 x i8> %a0) {
40 ; BTVER1-LABEL: shuf_01zzuuuuuuuuuuuu:
41 ; BTVER1:       # BB#0:
42 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
43 ; BTVER1-NEXT:    retq
44 ;
45 ; BTVER2-LABEL: shuf_01zzuuuuuuuuuuuu:
46 ; BTVER2:       # BB#0:
47 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
48 ; BTVER2-NEXT:    retq
49   %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>
50   ret <16 x i8> %s
51 }
52
53 define <16 x i8> @shuf_01zzzzzz23zzzzzz(<16 x i8> %a0) {
54 ; BTVER1-LABEL: shuf_01zzzzzz23zzzzzz:
55 ; BTVER1:       # BB#0:
56 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
57 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[2,3],zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
58 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
59 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
60 ; BTVER1-NEXT:    retq
61 ;
62 ; BTVER2-LABEL: shuf_01zzzzzz23zzzzzz:
63 ; BTVER2:       # BB#0:
64 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
65 ; BTVER2-NEXT:    retq
66   %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>
67   ret <16 x i8> %s
68 }
69
70 define <16 x i8> @shuf_1zzzuuuuuuuuuuuu(<16 x i8> %a0) {
71 ; ALL-LABEL: shuf_1zzzuuuuuuuuuuuu:
72 ; ALL:       # BB#0:
73 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[1],zero,zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
74 ; ALL-NEXT:    retq
75   %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>
76   ret <16 x i8> %s
77 }
78
79 define <8 x i16> @shuf_1zzzuuuu(<8 x i16> %a0) {
80 ; ALL-LABEL: shuf_1zzzuuuu:
81 ; ALL:       # BB#0:
82 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[2,3],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
83 ; ALL-NEXT:    retq
84   %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>
85   ret <8 x i16> %s
86 }
87
88 define <8 x i16> @shuf_12zzuuuu(<8 x i16> %a0) {
89 ; ALL-LABEL: shuf_12zzuuuu:
90 ; ALL:       # BB#0:
91 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[2,3,4,5],zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
92 ; ALL-NEXT:    retq
93   %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>
94   ret <8 x i16> %s
95 }
96
97 define <8 x i16> @shuf_012zuuuu(<8 x i16> %a0) {
98 ; ALL-LABEL: shuf_012zuuuu:
99 ; ALL:       # BB#0:
100 ; ALL-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],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 0, i32 1, i32 2, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
103   ret <8 x i16> %s
104 }
105
106 define <8 x i16> @shuf_0zzz1zzz(<8 x i16> %a0) {
107 ; BTVER1-LABEL: shuf_0zzz1zzz:
108 ; BTVER1:       # BB#0:
109 ; BTVER1-NEXT:    movaps %xmm0, %xmm1
110 ; BTVER1-NEXT:    extrq {{.*#+}} xmm1 = xmm1[2,3],zero,zero,zero,zero,zero,zero,xmm1[u,u,u,u,u,u,u,u]
111 ; BTVER1-NEXT:    extrq {{.*#+}} xmm0 = xmm0[0,1],zero,zero,zero,zero,zero,zero,xmm0[u,u,u,u,u,u,u,u]
112 ; BTVER1-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
113 ; BTVER1-NEXT:    retq
114 ;
115 ; BTVER2-LABEL: shuf_0zzz1zzz:
116 ; BTVER2:       # BB#0:
117 ; BTVER2-NEXT:    vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
118 ; BTVER2-NEXT:    retq
119   %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>
120   ret <8 x i16> %s
121 }
122
123 define <4 x i32> @shuf_0z1z(<4 x i32> %a0) {
124 ; BTVER1-LABEL: shuf_0z1z:
125 ; BTVER1:       # BB#0:
126 ; BTVER1-NEXT:    pxor %xmm1, %xmm1
127 ; BTVER1-NEXT:    punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
128 ; BTVER1-NEXT:    retq
129 ;
130 ; BTVER2-LABEL: shuf_0z1z:
131 ; BTVER2:       # BB#0:
132 ; BTVER2-NEXT:    vpmovzxdq {{.*#+}} xmm0 = xmm0[0],zero,xmm0[1],zero
133 ; BTVER2-NEXT:    retq
134   %s = shufflevector <4 x i32> %a0, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 1, i32 4>
135   ret <4 x i32> %s
136 }
137
138 ;
139 ; INSERTQI
140 ;
141
142 define <16 x i8> @shuf_0_0_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
143 ; ALL-LABEL: shuf_0_0_2_3_uuuu_uuuu_uuuu:
144 ; ALL:       # BB#0:
145 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,0,2,3,4,5,6,7,u,u,u,u,u,u,u,u]
146 ; ALL-NEXT:    retq
147   %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>
148   ret <16 x i8> %s
149 }
150
151 define <16 x i8> @shuf_0_16_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
152 ; ALL-LABEL: shuf_0_16_2_3_uuuu_uuuu_uuuu:
153 ; ALL:       # BB#0:
154 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[2,3,4,5,6,7,u,u,u,u,u,u,u,u]
155 ; ALL-NEXT:    retq
156   %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>
157   ret <16 x i8> %s
158 }
159
160 define <16 x i8> @shuf_16_1_2_3_uuuu_uuuu_uuuu(<16 x i8> %a0, <16 x i8> %a1) {
161 ; ALL-LABEL: shuf_16_1_2_3_uuuu_uuuu_uuuu:
162 ; ALL:       # BB#0:
163 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm1[0],xmm0[1,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 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>
166   ret <16 x i8> %s
167 }
168
169 define <8 x i16> @shuf_0823uuuu(<8 x i16> %a0, <8 x i16> %a1) {
170 ; ALL-LABEL: shuf_0823uuuu:
171 ; ALL:       # BB#0:
172 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1],xmm0[4,5,6,7,u,u,u,u,u,u,u,u]
173 ; ALL-NEXT:    retq
174   %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>
175   ret <8 x i16> %s
176 }
177
178 define <8 x i16> @shuf_0183uuuu(<8 x i16> %a0, <8 x i16> %a1) {
179 ; ALL-LABEL: shuf_0183uuuu:
180 ; ALL:       # BB#0:
181 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[0,1],xmm0[6,7,u,u,u,u,u,u,u,u]
182 ; ALL-NEXT:    retq
183   %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>
184   ret <8 x i16> %s
185 }
186
187 define <8 x i16> @shuf_0128uuuu(<8 x i16> %a0, <8 x i16> %a1) {
188 ; ALL-LABEL: shuf_0128uuuu:
189 ; ALL:       # BB#0:
190 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],xmm1[0,1],xmm0[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 1, i32 2, i32 8, i32 undef, i32 undef, i32 undef, i32 undef>
193   ret <8 x i16> %s
194 }
195
196 define <8 x i16> @shuf_0893uuuu(<8 x i16> %a0, <8 x i16> %a1) {
197 ; ALL-LABEL: shuf_0893uuuu:
198 ; ALL:       # BB#0:
199 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1,2,3],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 8, i32 9, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
202   ret <8 x i16> %s
203 }
204
205 define <8 x i16> @shuf_089Auuuu(<8 x i16> %a0, <8 x i16> %a1) {
206 ; ALL-LABEL: shuf_089Auuuu:
207 ; ALL:       # BB#0:
208 ; ALL-NEXT:    insertq {{.*#+}} xmm0 = xmm0[0,1],xmm1[0,1,2,3,4,5],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 8, i32 9, i32 10, i32 undef, i32 undef, i32 undef, i32 undef>
211   ret <8 x i16> %s
212 }
213
214 define <8 x i16> @shuf_089uuuuu(<8 x i16> %a0, <8 x i16> %a1) {
215 ; ALL-LABEL: shuf_089uuuuu:
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 undef, i32 undef, i32 undef, i32 undef, i32 undef>
220   ret <8 x i16> %s
221 }