1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE,SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefixes=SSE,SSE41
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+xop,+avx | FileCheck %s --check-prefixes=XOP,XOPAVX1
7 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+xop,+avx2 | FileCheck %s --check-prefixes=XOP,XOPAVX2
8 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512dq | FileCheck %s --check-prefixes=AVX512,AVX512DQ
9 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw | FileCheck %s --check-prefixes=AVX512,AVX512BW
10 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512dq,+avx512vl | FileCheck %s --check-prefixes=AVX512VL,AVX512DQVL
11 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl | FileCheck %s --check-prefixes=AVX512VL,AVX512BWVL
13 ; Just one 32-bit run to make sure we do reasonable things for i64 shifts.
14 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86-SSE
20 define <2 x i64> @var_shift_v2i64(<2 x i64> %a, <2 x i64> %b) nounwind {
21 ; SSE2-LABEL: var_shift_v2i64:
23 ; SSE2-NEXT: movdqa %xmm0, %xmm2
24 ; SSE2-NEXT: psllq %xmm1, %xmm2
25 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[2,3,2,3]
26 ; SSE2-NEXT: psllq %xmm1, %xmm0
27 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm2[0],xmm0[1]
30 ; SSE41-LABEL: var_shift_v2i64:
32 ; SSE41-NEXT: movdqa %xmm0, %xmm2
33 ; SSE41-NEXT: psllq %xmm1, %xmm2
34 ; SSE41-NEXT: pshufd {{.*#+}} xmm1 = xmm1[2,3,2,3]
35 ; SSE41-NEXT: psllq %xmm1, %xmm0
36 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm2[0,1,2,3],xmm0[4,5,6,7]
39 ; AVX1-LABEL: var_shift_v2i64:
41 ; AVX1-NEXT: vpsllq %xmm1, %xmm0, %xmm2
42 ; AVX1-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[2,3,2,3]
43 ; AVX1-NEXT: vpsllq %xmm1, %xmm0, %xmm0
44 ; AVX1-NEXT: vpblendw {{.*#+}} xmm0 = xmm2[0,1,2,3],xmm0[4,5,6,7]
47 ; AVX2-LABEL: var_shift_v2i64:
49 ; AVX2-NEXT: vpsllvq %xmm1, %xmm0, %xmm0
52 ; XOPAVX1-LABEL: var_shift_v2i64:
54 ; XOPAVX1-NEXT: vpshlq %xmm1, %xmm0, %xmm0
57 ; XOPAVX2-LABEL: var_shift_v2i64:
59 ; XOPAVX2-NEXT: vpsllvq %xmm1, %xmm0, %xmm0
62 ; AVX512-LABEL: var_shift_v2i64:
64 ; AVX512-NEXT: vpsllvq %xmm1, %xmm0, %xmm0
67 ; AVX512VL-LABEL: var_shift_v2i64:
69 ; AVX512VL-NEXT: vpsllvq %xmm1, %xmm0, %xmm0
72 ; X86-SSE-LABEL: var_shift_v2i64:
74 ; X86-SSE-NEXT: movdqa %xmm0, %xmm2
75 ; X86-SSE-NEXT: psllq %xmm1, %xmm2
76 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[2,3,2,3]
77 ; X86-SSE-NEXT: psllq %xmm1, %xmm0
78 ; X86-SSE-NEXT: movsd {{.*#+}} xmm0 = xmm2[0],xmm0[1]
80 %shift = shl <2 x i64> %a, %b
84 define <4 x i32> @var_shift_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
85 ; SSE2-LABEL: var_shift_v4i32:
87 ; SSE2-NEXT: pslld $23, %xmm1
88 ; SSE2-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
89 ; SSE2-NEXT: cvttps2dq %xmm1, %xmm1
90 ; SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
91 ; SSE2-NEXT: pmuludq %xmm1, %xmm0
92 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
93 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
94 ; SSE2-NEXT: pmuludq %xmm2, %xmm1
95 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
96 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
99 ; SSE41-LABEL: var_shift_v4i32:
101 ; SSE41-NEXT: pslld $23, %xmm1
102 ; SSE41-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
103 ; SSE41-NEXT: cvttps2dq %xmm1, %xmm1
104 ; SSE41-NEXT: pmulld %xmm1, %xmm0
107 ; AVX1-LABEL: var_shift_v4i32:
109 ; AVX1-NEXT: vpslld $23, %xmm1, %xmm1
110 ; AVX1-NEXT: vpaddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
111 ; AVX1-NEXT: vcvttps2dq %xmm1, %xmm1
112 ; AVX1-NEXT: vpmulld %xmm1, %xmm0, %xmm0
115 ; AVX2-LABEL: var_shift_v4i32:
117 ; AVX2-NEXT: vpsllvd %xmm1, %xmm0, %xmm0
120 ; XOPAVX1-LABEL: var_shift_v4i32:
122 ; XOPAVX1-NEXT: vpshld %xmm1, %xmm0, %xmm0
125 ; XOPAVX2-LABEL: var_shift_v4i32:
127 ; XOPAVX2-NEXT: vpsllvd %xmm1, %xmm0, %xmm0
130 ; AVX512-LABEL: var_shift_v4i32:
132 ; AVX512-NEXT: vpsllvd %xmm1, %xmm0, %xmm0
135 ; AVX512VL-LABEL: var_shift_v4i32:
137 ; AVX512VL-NEXT: vpsllvd %xmm1, %xmm0, %xmm0
138 ; AVX512VL-NEXT: retq
140 ; X86-SSE-LABEL: var_shift_v4i32:
142 ; X86-SSE-NEXT: pslld $23, %xmm1
143 ; X86-SSE-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
144 ; X86-SSE-NEXT: cvttps2dq %xmm1, %xmm1
145 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
146 ; X86-SSE-NEXT: pmuludq %xmm1, %xmm0
147 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
148 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
149 ; X86-SSE-NEXT: pmuludq %xmm2, %xmm1
150 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
151 ; X86-SSE-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
153 %shift = shl <4 x i32> %a, %b
157 define <8 x i16> @var_shift_v8i16(<8 x i16> %a, <8 x i16> %b) nounwind {
158 ; SSE2-LABEL: var_shift_v8i16:
160 ; SSE2-NEXT: movdqa %xmm1, %xmm2
161 ; SSE2-NEXT: punpckhwd {{.*#+}} xmm2 = xmm2[4,4,5,5,6,6,7,7]
162 ; SSE2-NEXT: pslld $23, %xmm2
163 ; SSE2-NEXT: movdqa {{.*#+}} xmm3 = [1065353216,1065353216,1065353216,1065353216]
164 ; SSE2-NEXT: paddd %xmm3, %xmm2
165 ; SSE2-NEXT: cvttps2dq %xmm2, %xmm2
166 ; SSE2-NEXT: pslld $16, %xmm2
167 ; SSE2-NEXT: psrad $16, %xmm2
168 ; SSE2-NEXT: punpcklwd {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3]
169 ; SSE2-NEXT: pslld $23, %xmm1
170 ; SSE2-NEXT: paddd %xmm3, %xmm1
171 ; SSE2-NEXT: cvttps2dq %xmm1, %xmm1
172 ; SSE2-NEXT: pslld $16, %xmm1
173 ; SSE2-NEXT: psrad $16, %xmm1
174 ; SSE2-NEXT: packssdw %xmm2, %xmm1
175 ; SSE2-NEXT: pmullw %xmm1, %xmm0
178 ; SSE41-LABEL: var_shift_v8i16:
180 ; SSE41-NEXT: pmovzxwd {{.*#+}} xmm2 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero
181 ; SSE41-NEXT: punpckhwd {{.*#+}} xmm1 = xmm1[4,4,5,5,6,6,7,7]
182 ; SSE41-NEXT: pslld $23, %xmm1
183 ; SSE41-NEXT: movdqa {{.*#+}} xmm3 = [1065353216,1065353216,1065353216,1065353216]
184 ; SSE41-NEXT: paddd %xmm3, %xmm1
185 ; SSE41-NEXT: cvttps2dq %xmm1, %xmm1
186 ; SSE41-NEXT: pslld $23, %xmm2
187 ; SSE41-NEXT: paddd %xmm3, %xmm2
188 ; SSE41-NEXT: cvttps2dq %xmm2, %xmm2
189 ; SSE41-NEXT: packusdw %xmm1, %xmm2
190 ; SSE41-NEXT: pmullw %xmm2, %xmm0
193 ; AVX1-LABEL: var_shift_v8i16:
195 ; AVX1-NEXT: vpunpckhwd {{.*#+}} xmm2 = xmm1[4,4,5,5,6,6,7,7]
196 ; AVX1-NEXT: vpslld $23, %xmm2, %xmm2
197 ; AVX1-NEXT: vbroadcastss {{.*#+}} xmm3 = [1065353216,1065353216,1065353216,1065353216]
198 ; AVX1-NEXT: vpaddd %xmm3, %xmm2, %xmm2
199 ; AVX1-NEXT: vcvttps2dq %xmm2, %xmm2
200 ; AVX1-NEXT: vpmovzxwd {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero
201 ; AVX1-NEXT: vpslld $23, %xmm1, %xmm1
202 ; AVX1-NEXT: vpaddd %xmm3, %xmm1, %xmm1
203 ; AVX1-NEXT: vcvttps2dq %xmm1, %xmm1
204 ; AVX1-NEXT: vpackusdw %xmm2, %xmm1, %xmm1
205 ; AVX1-NEXT: vpmullw %xmm1, %xmm0, %xmm0
208 ; AVX2-LABEL: var_shift_v8i16:
210 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero
211 ; AVX2-NEXT: vpmovzxwd {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
212 ; AVX2-NEXT: vpsllvd %ymm1, %ymm0, %ymm0
213 ; AVX2-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13,u,u,u,u,u,u,u,u,16,17,20,21,24,25,28,29,u,u,u,u,u,u,u,u]
214 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
215 ; AVX2-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
216 ; AVX2-NEXT: vzeroupper
219 ; XOP-LABEL: var_shift_v8i16:
221 ; XOP-NEXT: vpshlw %xmm1, %xmm0, %xmm0
224 ; AVX512DQ-LABEL: var_shift_v8i16:
226 ; AVX512DQ-NEXT: vpmovzxwd {{.*#+}} ymm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero
227 ; AVX512DQ-NEXT: vpmovzxwd {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
228 ; AVX512DQ-NEXT: vpsllvd %ymm1, %ymm0, %ymm0
229 ; AVX512DQ-NEXT: vpmovdw %zmm0, %ymm0
230 ; AVX512DQ-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
231 ; AVX512DQ-NEXT: vzeroupper
232 ; AVX512DQ-NEXT: retq
234 ; AVX512BW-LABEL: var_shift_v8i16:
236 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
237 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
238 ; AVX512BW-NEXT: vpsllvw %zmm1, %zmm0, %zmm0
239 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $zmm0
240 ; AVX512BW-NEXT: vzeroupper
241 ; AVX512BW-NEXT: retq
243 ; AVX512DQVL-LABEL: var_shift_v8i16:
244 ; AVX512DQVL: # %bb.0:
245 ; AVX512DQVL-NEXT: vpmovzxwd {{.*#+}} ymm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero
246 ; AVX512DQVL-NEXT: vpmovzxwd {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero
247 ; AVX512DQVL-NEXT: vpsllvd %ymm1, %ymm0, %ymm0
248 ; AVX512DQVL-NEXT: vpmovdw %ymm0, %xmm0
249 ; AVX512DQVL-NEXT: vzeroupper
250 ; AVX512DQVL-NEXT: retq
252 ; AVX512BWVL-LABEL: var_shift_v8i16:
253 ; AVX512BWVL: # %bb.0:
254 ; AVX512BWVL-NEXT: vpsllvw %xmm1, %xmm0, %xmm0
255 ; AVX512BWVL-NEXT: retq
257 ; X86-SSE-LABEL: var_shift_v8i16:
259 ; X86-SSE-NEXT: movdqa %xmm1, %xmm2
260 ; X86-SSE-NEXT: punpckhwd {{.*#+}} xmm2 = xmm2[4,4,5,5,6,6,7,7]
261 ; X86-SSE-NEXT: pslld $23, %xmm2
262 ; X86-SSE-NEXT: movdqa {{.*#+}} xmm3 = [1065353216,1065353216,1065353216,1065353216]
263 ; X86-SSE-NEXT: paddd %xmm3, %xmm2
264 ; X86-SSE-NEXT: cvttps2dq %xmm2, %xmm2
265 ; X86-SSE-NEXT: pslld $16, %xmm2
266 ; X86-SSE-NEXT: psrad $16, %xmm2
267 ; X86-SSE-NEXT: punpcklwd {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3]
268 ; X86-SSE-NEXT: pslld $23, %xmm1
269 ; X86-SSE-NEXT: paddd %xmm3, %xmm1
270 ; X86-SSE-NEXT: cvttps2dq %xmm1, %xmm1
271 ; X86-SSE-NEXT: pslld $16, %xmm1
272 ; X86-SSE-NEXT: psrad $16, %xmm1
273 ; X86-SSE-NEXT: packssdw %xmm2, %xmm1
274 ; X86-SSE-NEXT: pmullw %xmm1, %xmm0
276 %shift = shl <8 x i16> %a, %b
280 define <16 x i8> @var_shift_v16i8(<16 x i8> %a, <16 x i8> %b) nounwind {
281 ; SSE2-LABEL: var_shift_v16i8:
283 ; SSE2-NEXT: psllw $5, %xmm1
284 ; SSE2-NEXT: pxor %xmm2, %xmm2
285 ; SSE2-NEXT: pxor %xmm3, %xmm3
286 ; SSE2-NEXT: pcmpgtb %xmm1, %xmm3
287 ; SSE2-NEXT: movdqa %xmm3, %xmm4
288 ; SSE2-NEXT: pandn %xmm0, %xmm4
289 ; SSE2-NEXT: psllw $4, %xmm0
290 ; SSE2-NEXT: pand %xmm3, %xmm0
291 ; SSE2-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
292 ; SSE2-NEXT: por %xmm4, %xmm0
293 ; SSE2-NEXT: paddb %xmm1, %xmm1
294 ; SSE2-NEXT: pxor %xmm3, %xmm3
295 ; SSE2-NEXT: pcmpgtb %xmm1, %xmm3
296 ; SSE2-NEXT: movdqa %xmm3, %xmm4
297 ; SSE2-NEXT: pandn %xmm0, %xmm4
298 ; SSE2-NEXT: psllw $2, %xmm0
299 ; SSE2-NEXT: pand %xmm3, %xmm0
300 ; SSE2-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
301 ; SSE2-NEXT: por %xmm4, %xmm0
302 ; SSE2-NEXT: paddb %xmm1, %xmm1
303 ; SSE2-NEXT: pcmpgtb %xmm1, %xmm2
304 ; SSE2-NEXT: movdqa %xmm2, %xmm1
305 ; SSE2-NEXT: pandn %xmm0, %xmm1
306 ; SSE2-NEXT: paddb %xmm0, %xmm0
307 ; SSE2-NEXT: pand %xmm2, %xmm0
308 ; SSE2-NEXT: por %xmm1, %xmm0
311 ; SSE41-LABEL: var_shift_v16i8:
313 ; SSE41-NEXT: movdqa %xmm0, %xmm2
314 ; SSE41-NEXT: psllw $5, %xmm1
315 ; SSE41-NEXT: movdqa %xmm0, %xmm3
316 ; SSE41-NEXT: psllw $4, %xmm3
317 ; SSE41-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3
318 ; SSE41-NEXT: movdqa %xmm1, %xmm0
319 ; SSE41-NEXT: pblendvb %xmm0, %xmm3, %xmm2
320 ; SSE41-NEXT: movdqa %xmm2, %xmm3
321 ; SSE41-NEXT: psllw $2, %xmm3
322 ; SSE41-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3
323 ; SSE41-NEXT: paddb %xmm1, %xmm1
324 ; SSE41-NEXT: movdqa %xmm1, %xmm0
325 ; SSE41-NEXT: pblendvb %xmm0, %xmm3, %xmm2
326 ; SSE41-NEXT: movdqa %xmm2, %xmm3
327 ; SSE41-NEXT: paddb %xmm2, %xmm3
328 ; SSE41-NEXT: paddb %xmm1, %xmm1
329 ; SSE41-NEXT: movdqa %xmm1, %xmm0
330 ; SSE41-NEXT: pblendvb %xmm0, %xmm3, %xmm2
331 ; SSE41-NEXT: movdqa %xmm2, %xmm0
334 ; AVX-LABEL: var_shift_v16i8:
336 ; AVX-NEXT: vpsllw $5, %xmm1, %xmm1
337 ; AVX-NEXT: vpsllw $4, %xmm0, %xmm2
338 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2
339 ; AVX-NEXT: vpblendvb %xmm1, %xmm2, %xmm0, %xmm0
340 ; AVX-NEXT: vpsllw $2, %xmm0, %xmm2
341 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2
342 ; AVX-NEXT: vpaddb %xmm1, %xmm1, %xmm1
343 ; AVX-NEXT: vpblendvb %xmm1, %xmm2, %xmm0, %xmm0
344 ; AVX-NEXT: vpaddb %xmm0, %xmm0, %xmm2
345 ; AVX-NEXT: vpaddb %xmm1, %xmm1, %xmm1
346 ; AVX-NEXT: vpblendvb %xmm1, %xmm2, %xmm0, %xmm0
349 ; XOP-LABEL: var_shift_v16i8:
351 ; XOP-NEXT: vpshlb %xmm1, %xmm0, %xmm0
354 ; AVX512DQ-LABEL: var_shift_v16i8:
356 ; AVX512DQ-NEXT: vpmovzxbd {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero,xmm1[8],zero,zero,zero,xmm1[9],zero,zero,zero,xmm1[10],zero,zero,zero,xmm1[11],zero,zero,zero,xmm1[12],zero,zero,zero,xmm1[13],zero,zero,zero,xmm1[14],zero,zero,zero,xmm1[15],zero,zero,zero
357 ; AVX512DQ-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
358 ; AVX512DQ-NEXT: vpsllvd %zmm1, %zmm0, %zmm0
359 ; AVX512DQ-NEXT: vpmovdb %zmm0, %xmm0
360 ; AVX512DQ-NEXT: vzeroupper
361 ; AVX512DQ-NEXT: retq
363 ; AVX512BW-LABEL: var_shift_v16i8:
365 ; AVX512BW-NEXT: vpmovzxbw {{.*#+}} ymm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero,xmm1[8],zero,xmm1[9],zero,xmm1[10],zero,xmm1[11],zero,xmm1[12],zero,xmm1[13],zero,xmm1[14],zero,xmm1[15],zero
366 ; AVX512BW-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
367 ; AVX512BW-NEXT: vpsllvw %zmm1, %zmm0, %zmm0
368 ; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0
369 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
370 ; AVX512BW-NEXT: vzeroupper
371 ; AVX512BW-NEXT: retq
373 ; AVX512DQVL-LABEL: var_shift_v16i8:
374 ; AVX512DQVL: # %bb.0:
375 ; AVX512DQVL-NEXT: vpmovzxbd {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero,xmm1[8],zero,zero,zero,xmm1[9],zero,zero,zero,xmm1[10],zero,zero,zero,xmm1[11],zero,zero,zero,xmm1[12],zero,zero,zero,xmm1[13],zero,zero,zero,xmm1[14],zero,zero,zero,xmm1[15],zero,zero,zero
376 ; AVX512DQVL-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
377 ; AVX512DQVL-NEXT: vpsllvd %zmm1, %zmm0, %zmm0
378 ; AVX512DQVL-NEXT: vpmovdb %zmm0, %xmm0
379 ; AVX512DQVL-NEXT: vzeroupper
380 ; AVX512DQVL-NEXT: retq
382 ; AVX512BWVL-LABEL: var_shift_v16i8:
383 ; AVX512BWVL: # %bb.0:
384 ; AVX512BWVL-NEXT: vpmovzxbw {{.*#+}} ymm1 = xmm1[0],zero,xmm1[1],zero,xmm1[2],zero,xmm1[3],zero,xmm1[4],zero,xmm1[5],zero,xmm1[6],zero,xmm1[7],zero,xmm1[8],zero,xmm1[9],zero,xmm1[10],zero,xmm1[11],zero,xmm1[12],zero,xmm1[13],zero,xmm1[14],zero,xmm1[15],zero
385 ; AVX512BWVL-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
386 ; AVX512BWVL-NEXT: vpsllvw %ymm1, %ymm0, %ymm0
387 ; AVX512BWVL-NEXT: vpmovwb %ymm0, %xmm0
388 ; AVX512BWVL-NEXT: vzeroupper
389 ; AVX512BWVL-NEXT: retq
391 ; X86-SSE-LABEL: var_shift_v16i8:
393 ; X86-SSE-NEXT: psllw $5, %xmm1
394 ; X86-SSE-NEXT: pxor %xmm2, %xmm2
395 ; X86-SSE-NEXT: pxor %xmm3, %xmm3
396 ; X86-SSE-NEXT: pcmpgtb %xmm1, %xmm3
397 ; X86-SSE-NEXT: movdqa %xmm3, %xmm4
398 ; X86-SSE-NEXT: pandn %xmm0, %xmm4
399 ; X86-SSE-NEXT: psllw $4, %xmm0
400 ; X86-SSE-NEXT: pand %xmm3, %xmm0
401 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
402 ; X86-SSE-NEXT: por %xmm4, %xmm0
403 ; X86-SSE-NEXT: paddb %xmm1, %xmm1
404 ; X86-SSE-NEXT: pxor %xmm3, %xmm3
405 ; X86-SSE-NEXT: pcmpgtb %xmm1, %xmm3
406 ; X86-SSE-NEXT: movdqa %xmm3, %xmm4
407 ; X86-SSE-NEXT: pandn %xmm0, %xmm4
408 ; X86-SSE-NEXT: psllw $2, %xmm0
409 ; X86-SSE-NEXT: pand %xmm3, %xmm0
410 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
411 ; X86-SSE-NEXT: por %xmm4, %xmm0
412 ; X86-SSE-NEXT: paddb %xmm1, %xmm1
413 ; X86-SSE-NEXT: pcmpgtb %xmm1, %xmm2
414 ; X86-SSE-NEXT: movdqa %xmm2, %xmm1
415 ; X86-SSE-NEXT: pandn %xmm0, %xmm1
416 ; X86-SSE-NEXT: paddb %xmm0, %xmm0
417 ; X86-SSE-NEXT: pand %xmm2, %xmm0
418 ; X86-SSE-NEXT: por %xmm1, %xmm0
420 %shift = shl <16 x i8> %a, %b
425 ; Uniform Variable Shifts
428 define <2 x i64> @splatvar_shift_v2i64(<2 x i64> %a, <2 x i64> %b) nounwind {
429 ; SSE-LABEL: splatvar_shift_v2i64:
431 ; SSE-NEXT: psllq %xmm1, %xmm0
434 ; AVX-LABEL: splatvar_shift_v2i64:
436 ; AVX-NEXT: vpsllq %xmm1, %xmm0, %xmm0
439 ; XOP-LABEL: splatvar_shift_v2i64:
441 ; XOP-NEXT: vpsllq %xmm1, %xmm0, %xmm0
444 ; AVX512-LABEL: splatvar_shift_v2i64:
446 ; AVX512-NEXT: vpsllq %xmm1, %xmm0, %xmm0
449 ; AVX512VL-LABEL: splatvar_shift_v2i64:
451 ; AVX512VL-NEXT: vpsllq %xmm1, %xmm0, %xmm0
452 ; AVX512VL-NEXT: retq
454 ; X86-SSE-LABEL: splatvar_shift_v2i64:
456 ; X86-SSE-NEXT: psllq %xmm1, %xmm0
458 %splat = shufflevector <2 x i64> %b, <2 x i64> undef, <2 x i32> zeroinitializer
459 %shift = shl <2 x i64> %a, %splat
463 define <4 x i32> @splatvar_shift_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
464 ; SSE2-LABEL: splatvar_shift_v4i32:
466 ; SSE2-NEXT: xorps %xmm2, %xmm2
467 ; SSE2-NEXT: movss {{.*#+}} xmm2 = xmm1[0],xmm2[1,2,3]
468 ; SSE2-NEXT: pslld %xmm2, %xmm0
471 ; SSE41-LABEL: splatvar_shift_v4i32:
473 ; SSE41-NEXT: pmovzxdq {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero
474 ; SSE41-NEXT: pslld %xmm1, %xmm0
477 ; AVX-LABEL: splatvar_shift_v4i32:
479 ; AVX-NEXT: vpmovzxdq {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero
480 ; AVX-NEXT: vpslld %xmm1, %xmm0, %xmm0
483 ; XOP-LABEL: splatvar_shift_v4i32:
485 ; XOP-NEXT: vpmovzxdq {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero
486 ; XOP-NEXT: vpslld %xmm1, %xmm0, %xmm0
489 ; AVX512-LABEL: splatvar_shift_v4i32:
491 ; AVX512-NEXT: vpmovzxdq {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero
492 ; AVX512-NEXT: vpslld %xmm1, %xmm0, %xmm0
495 ; AVX512VL-LABEL: splatvar_shift_v4i32:
497 ; AVX512VL-NEXT: vpmovzxdq {{.*#+}} xmm1 = xmm1[0],zero,xmm1[1],zero
498 ; AVX512VL-NEXT: vpslld %xmm1, %xmm0, %xmm0
499 ; AVX512VL-NEXT: retq
501 ; X86-SSE-LABEL: splatvar_shift_v4i32:
503 ; X86-SSE-NEXT: xorps %xmm2, %xmm2
504 ; X86-SSE-NEXT: movss {{.*#+}} xmm2 = xmm1[0],xmm2[1,2,3]
505 ; X86-SSE-NEXT: pslld %xmm2, %xmm0
507 %splat = shufflevector <4 x i32> %b, <4 x i32> undef, <4 x i32> zeroinitializer
508 %shift = shl <4 x i32> %a, %splat
512 define <8 x i16> @splatvar_shift_v8i16(<8 x i16> %a, <8 x i16> %b) nounwind {
513 ; SSE2-LABEL: splatvar_shift_v8i16:
515 ; SSE2-NEXT: pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0,1]
516 ; SSE2-NEXT: psrldq {{.*#+}} xmm1 = xmm1[14,15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
517 ; SSE2-NEXT: psllw %xmm1, %xmm0
520 ; SSE41-LABEL: splatvar_shift_v8i16:
522 ; SSE41-NEXT: pmovzxwq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero
523 ; SSE41-NEXT: psllw %xmm1, %xmm0
526 ; AVX-LABEL: splatvar_shift_v8i16:
528 ; AVX-NEXT: vpmovzxwq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero
529 ; AVX-NEXT: vpsllw %xmm1, %xmm0, %xmm0
532 ; XOP-LABEL: splatvar_shift_v8i16:
534 ; XOP-NEXT: vpmovzxwq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero
535 ; XOP-NEXT: vpsllw %xmm1, %xmm0, %xmm0
538 ; AVX512-LABEL: splatvar_shift_v8i16:
540 ; AVX512-NEXT: vpmovzxwq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero
541 ; AVX512-NEXT: vpsllw %xmm1, %xmm0, %xmm0
544 ; AVX512VL-LABEL: splatvar_shift_v8i16:
546 ; AVX512VL-NEXT: vpmovzxwq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero
547 ; AVX512VL-NEXT: vpsllw %xmm1, %xmm0, %xmm0
548 ; AVX512VL-NEXT: retq
550 ; X86-SSE-LABEL: splatvar_shift_v8i16:
552 ; X86-SSE-NEXT: pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0,1]
553 ; X86-SSE-NEXT: psrldq {{.*#+}} xmm1 = xmm1[14,15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
554 ; X86-SSE-NEXT: psllw %xmm1, %xmm0
556 %splat = shufflevector <8 x i16> %b, <8 x i16> undef, <8 x i32> zeroinitializer
557 %shift = shl <8 x i16> %a, %splat
561 define <16 x i8> @splatvar_shift_v16i8(<16 x i8> %a, <16 x i8> %b) nounwind {
562 ; SSE2-LABEL: splatvar_shift_v16i8:
564 ; SSE2-NEXT: pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0]
565 ; SSE2-NEXT: psrldq {{.*#+}} xmm1 = xmm1[15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
566 ; SSE2-NEXT: psllw %xmm1, %xmm0
567 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm2
568 ; SSE2-NEXT: psllw %xmm1, %xmm2
569 ; SSE2-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
570 ; SSE2-NEXT: pshuflw {{.*#+}} xmm1 = xmm2[0,0,0,0,4,5,6,7]
571 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,0,0,0]
572 ; SSE2-NEXT: pand %xmm1, %xmm0
575 ; SSE41-LABEL: splatvar_shift_v16i8:
577 ; SSE41-NEXT: pmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
578 ; SSE41-NEXT: psllw %xmm1, %xmm0
579 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
580 ; SSE41-NEXT: psllw %xmm1, %xmm2
581 ; SSE41-NEXT: pxor %xmm1, %xmm1
582 ; SSE41-NEXT: pshufb %xmm1, %xmm2
583 ; SSE41-NEXT: pand %xmm2, %xmm0
586 ; AVX1-LABEL: splatvar_shift_v16i8:
588 ; AVX1-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
589 ; AVX1-NEXT: vpsllw %xmm1, %xmm0, %xmm0
590 ; AVX1-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
591 ; AVX1-NEXT: vpsllw %xmm1, %xmm2, %xmm1
592 ; AVX1-NEXT: vpxor %xmm2, %xmm2, %xmm2
593 ; AVX1-NEXT: vpshufb %xmm2, %xmm1, %xmm1
594 ; AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0
597 ; AVX2-LABEL: splatvar_shift_v16i8:
599 ; AVX2-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
600 ; AVX2-NEXT: vpsllw %xmm1, %xmm0, %xmm0
601 ; AVX2-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
602 ; AVX2-NEXT: vpsllw %xmm1, %xmm2, %xmm1
603 ; AVX2-NEXT: vpbroadcastb %xmm1, %xmm1
604 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
607 ; XOPAVX1-LABEL: splatvar_shift_v16i8:
609 ; XOPAVX1-NEXT: vpxor %xmm2, %xmm2, %xmm2
610 ; XOPAVX1-NEXT: vpshufb %xmm2, %xmm1, %xmm1
611 ; XOPAVX1-NEXT: vpshlb %xmm1, %xmm0, %xmm0
614 ; XOPAVX2-LABEL: splatvar_shift_v16i8:
616 ; XOPAVX2-NEXT: vpbroadcastb %xmm1, %xmm1
617 ; XOPAVX2-NEXT: vpshlb %xmm1, %xmm0, %xmm0
620 ; AVX512DQ-LABEL: splatvar_shift_v16i8:
622 ; AVX512DQ-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
623 ; AVX512DQ-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
624 ; AVX512DQ-NEXT: vpslld %xmm1, %zmm0, %zmm0
625 ; AVX512DQ-NEXT: vpmovdb %zmm0, %xmm0
626 ; AVX512DQ-NEXT: vzeroupper
627 ; AVX512DQ-NEXT: retq
629 ; AVX512BW-LABEL: splatvar_shift_v16i8:
631 ; AVX512BW-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
632 ; AVX512BW-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
633 ; AVX512BW-NEXT: vpsllw %xmm1, %ymm0, %ymm0
634 ; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0
635 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
636 ; AVX512BW-NEXT: vzeroupper
637 ; AVX512BW-NEXT: retq
639 ; AVX512DQVL-LABEL: splatvar_shift_v16i8:
640 ; AVX512DQVL: # %bb.0:
641 ; AVX512DQVL-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
642 ; AVX512DQVL-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
643 ; AVX512DQVL-NEXT: vpslld %xmm1, %zmm0, %zmm0
644 ; AVX512DQVL-NEXT: vpmovdb %zmm0, %xmm0
645 ; AVX512DQVL-NEXT: vzeroupper
646 ; AVX512DQVL-NEXT: retq
648 ; AVX512BWVL-LABEL: splatvar_shift_v16i8:
649 ; AVX512BWVL: # %bb.0:
650 ; AVX512BWVL-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
651 ; AVX512BWVL-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
652 ; AVX512BWVL-NEXT: vpsllw %xmm1, %ymm0, %ymm0
653 ; AVX512BWVL-NEXT: vpmovwb %ymm0, %xmm0
654 ; AVX512BWVL-NEXT: vzeroupper
655 ; AVX512BWVL-NEXT: retq
657 ; X86-SSE-LABEL: splatvar_shift_v16i8:
659 ; X86-SSE-NEXT: pslldq {{.*#+}} xmm1 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm1[0]
660 ; X86-SSE-NEXT: psrldq {{.*#+}} xmm1 = xmm1[15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
661 ; X86-SSE-NEXT: psllw %xmm1, %xmm0
662 ; X86-SSE-NEXT: pcmpeqd %xmm2, %xmm2
663 ; X86-SSE-NEXT: psllw %xmm1, %xmm2
664 ; X86-SSE-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
665 ; X86-SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm2[0,0,0,0,4,5,6,7]
666 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,0,0,0]
667 ; X86-SSE-NEXT: pand %xmm1, %xmm0
669 %splat = shufflevector <16 x i8> %b, <16 x i8> undef, <16 x i32> zeroinitializer
670 %shift = shl <16 x i8> %a, %splat
675 ; Uniform Variable Modulo Shifts
678 define <2 x i64> @splatvar_modulo_shift_v2i64(<2 x i64> %a, <2 x i64> %b) nounwind {
679 ; SSE-LABEL: splatvar_modulo_shift_v2i64:
681 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
682 ; SSE-NEXT: psllq %xmm1, %xmm0
685 ; AVX-LABEL: splatvar_modulo_shift_v2i64:
687 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
688 ; AVX-NEXT: vpsllq %xmm1, %xmm0, %xmm0
691 ; XOP-LABEL: splatvar_modulo_shift_v2i64:
693 ; XOP-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
694 ; XOP-NEXT: vpsllq %xmm1, %xmm0, %xmm0
697 ; AVX512-LABEL: splatvar_modulo_shift_v2i64:
699 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
700 ; AVX512-NEXT: vpsllq %xmm1, %xmm0, %xmm0
703 ; AVX512VL-LABEL: splatvar_modulo_shift_v2i64:
705 ; AVX512VL-NEXT: vpandq {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to2}, %xmm1, %xmm1
706 ; AVX512VL-NEXT: vpsllq %xmm1, %xmm0, %xmm0
707 ; AVX512VL-NEXT: retq
709 ; X86-SSE-LABEL: splatvar_modulo_shift_v2i64:
711 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
712 ; X86-SSE-NEXT: psllq %xmm1, %xmm0
714 %mod = and <2 x i64> %b, <i64 63, i64 63>
715 %splat = shufflevector <2 x i64> %mod, <2 x i64> undef, <2 x i32> zeroinitializer
716 %shift = shl <2 x i64> %a, %splat
720 define <4 x i32> @splatvar_modulo_shift_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
721 ; SSE-LABEL: splatvar_modulo_shift_v4i32:
723 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
724 ; SSE-NEXT: pslld %xmm1, %xmm0
727 ; AVX-LABEL: splatvar_modulo_shift_v4i32:
729 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
730 ; AVX-NEXT: vpslld %xmm1, %xmm0, %xmm0
733 ; XOP-LABEL: splatvar_modulo_shift_v4i32:
735 ; XOP-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
736 ; XOP-NEXT: vpslld %xmm1, %xmm0, %xmm0
739 ; AVX512-LABEL: splatvar_modulo_shift_v4i32:
741 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
742 ; AVX512-NEXT: vpslld %xmm1, %xmm0, %xmm0
745 ; AVX512VL-LABEL: splatvar_modulo_shift_v4i32:
747 ; AVX512VL-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
748 ; AVX512VL-NEXT: vpslld %xmm1, %xmm0, %xmm0
749 ; AVX512VL-NEXT: retq
751 ; X86-SSE-LABEL: splatvar_modulo_shift_v4i32:
753 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
754 ; X86-SSE-NEXT: pslld %xmm1, %xmm0
756 %mod = and <4 x i32> %b, <i32 31, i32 31, i32 31, i32 31>
757 %splat = shufflevector <4 x i32> %mod, <4 x i32> undef, <4 x i32> zeroinitializer
758 %shift = shl <4 x i32> %a, %splat
762 define <8 x i16> @splatvar_modulo_shift_v8i16(<8 x i16> %a, <8 x i16> %b) nounwind {
763 ; SSE-LABEL: splatvar_modulo_shift_v8i16:
765 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
766 ; SSE-NEXT: psllw %xmm1, %xmm0
769 ; AVX-LABEL: splatvar_modulo_shift_v8i16:
771 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
772 ; AVX-NEXT: vpsllw %xmm1, %xmm0, %xmm0
775 ; XOP-LABEL: splatvar_modulo_shift_v8i16:
777 ; XOP-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
778 ; XOP-NEXT: vpsllw %xmm1, %xmm0, %xmm0
781 ; AVX512-LABEL: splatvar_modulo_shift_v8i16:
783 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
784 ; AVX512-NEXT: vpsllw %xmm1, %xmm0, %xmm0
787 ; AVX512VL-LABEL: splatvar_modulo_shift_v8i16:
789 ; AVX512VL-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
790 ; AVX512VL-NEXT: vpsllw %xmm1, %xmm0, %xmm0
791 ; AVX512VL-NEXT: retq
793 ; X86-SSE-LABEL: splatvar_modulo_shift_v8i16:
795 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
796 ; X86-SSE-NEXT: psllw %xmm1, %xmm0
798 %mod = and <8 x i16> %b, <i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15, i16 15>
799 %splat = shufflevector <8 x i16> %mod, <8 x i16> undef, <8 x i32> zeroinitializer
800 %shift = shl <8 x i16> %a, %splat
804 define <16 x i8> @splatvar_modulo_shift_v16i8(<16 x i8> %a, <16 x i8> %b) nounwind {
805 ; SSE2-LABEL: splatvar_modulo_shift_v16i8:
807 ; SSE2-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
808 ; SSE2-NEXT: psllw %xmm1, %xmm0
809 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm2
810 ; SSE2-NEXT: psllw %xmm1, %xmm2
811 ; SSE2-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
812 ; SSE2-NEXT: pshuflw {{.*#+}} xmm1 = xmm2[0,0,0,0,4,5,6,7]
813 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,0,0,0]
814 ; SSE2-NEXT: pand %xmm1, %xmm0
817 ; SSE41-LABEL: splatvar_modulo_shift_v16i8:
819 ; SSE41-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
820 ; SSE41-NEXT: psllw %xmm1, %xmm0
821 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
822 ; SSE41-NEXT: psllw %xmm1, %xmm2
823 ; SSE41-NEXT: pxor %xmm1, %xmm1
824 ; SSE41-NEXT: pshufb %xmm1, %xmm2
825 ; SSE41-NEXT: pand %xmm2, %xmm0
828 ; AVX1-LABEL: splatvar_modulo_shift_v16i8:
830 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
831 ; AVX1-NEXT: vpsllw %xmm1, %xmm0, %xmm0
832 ; AVX1-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
833 ; AVX1-NEXT: vpsllw %xmm1, %xmm2, %xmm1
834 ; AVX1-NEXT: vpxor %xmm2, %xmm2, %xmm2
835 ; AVX1-NEXT: vpshufb %xmm2, %xmm1, %xmm1
836 ; AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0
839 ; AVX2-LABEL: splatvar_modulo_shift_v16i8:
841 ; AVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
842 ; AVX2-NEXT: vpsllw %xmm1, %xmm0, %xmm0
843 ; AVX2-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
844 ; AVX2-NEXT: vpsllw %xmm1, %xmm2, %xmm1
845 ; AVX2-NEXT: vpbroadcastb %xmm1, %xmm1
846 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
849 ; XOPAVX1-LABEL: splatvar_modulo_shift_v16i8:
851 ; XOPAVX1-NEXT: vpxor %xmm2, %xmm2, %xmm2
852 ; XOPAVX1-NEXT: vpshufb %xmm2, %xmm1, %xmm1
853 ; XOPAVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
854 ; XOPAVX1-NEXT: vpshlb %xmm1, %xmm0, %xmm0
857 ; XOPAVX2-LABEL: splatvar_modulo_shift_v16i8:
859 ; XOPAVX2-NEXT: vpbroadcastb %xmm1, %xmm1
860 ; XOPAVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
861 ; XOPAVX2-NEXT: vpshlb %xmm1, %xmm0, %xmm0
864 ; AVX512DQ-LABEL: splatvar_modulo_shift_v16i8:
866 ; AVX512DQ-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
867 ; AVX512DQ-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
868 ; AVX512DQ-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
869 ; AVX512DQ-NEXT: vpslld %xmm1, %zmm0, %zmm0
870 ; AVX512DQ-NEXT: vpmovdb %zmm0, %xmm0
871 ; AVX512DQ-NEXT: vzeroupper
872 ; AVX512DQ-NEXT: retq
874 ; AVX512BW-LABEL: splatvar_modulo_shift_v16i8:
876 ; AVX512BW-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
877 ; AVX512BW-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
878 ; AVX512BW-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
879 ; AVX512BW-NEXT: vpsllw %xmm1, %ymm0, %ymm0
880 ; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0
881 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
882 ; AVX512BW-NEXT: vzeroupper
883 ; AVX512BW-NEXT: retq
885 ; AVX512DQVL-LABEL: splatvar_modulo_shift_v16i8:
886 ; AVX512DQVL: # %bb.0:
887 ; AVX512DQVL-NEXT: vpandd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to4}, %xmm1, %xmm1
888 ; AVX512DQVL-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
889 ; AVX512DQVL-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
890 ; AVX512DQVL-NEXT: vpslld %xmm1, %zmm0, %zmm0
891 ; AVX512DQVL-NEXT: vpmovdb %zmm0, %xmm0
892 ; AVX512DQVL-NEXT: vzeroupper
893 ; AVX512DQVL-NEXT: retq
895 ; AVX512BWVL-LABEL: splatvar_modulo_shift_v16i8:
896 ; AVX512BWVL: # %bb.0:
897 ; AVX512BWVL-NEXT: vpandd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to4}, %xmm1, %xmm1
898 ; AVX512BWVL-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
899 ; AVX512BWVL-NEXT: vpmovzxbq {{.*#+}} xmm1 = xmm1[0],zero,zero,zero,zero,zero,zero,zero,xmm1[1],zero,zero,zero,zero,zero,zero,zero
900 ; AVX512BWVL-NEXT: vpsllw %xmm1, %ymm0, %ymm0
901 ; AVX512BWVL-NEXT: vpmovwb %ymm0, %xmm0
902 ; AVX512BWVL-NEXT: vzeroupper
903 ; AVX512BWVL-NEXT: retq
905 ; X86-SSE-LABEL: splatvar_modulo_shift_v16i8:
907 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
908 ; X86-SSE-NEXT: psllw %xmm1, %xmm0
909 ; X86-SSE-NEXT: pcmpeqd %xmm2, %xmm2
910 ; X86-SSE-NEXT: psllw %xmm1, %xmm2
911 ; X86-SSE-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
912 ; X86-SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm2[0,0,0,0,4,5,6,7]
913 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,0,0,0]
914 ; X86-SSE-NEXT: pand %xmm1, %xmm0
916 %mod = and <16 x i8> %b, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
917 %splat = shufflevector <16 x i8> %mod, <16 x i8> undef, <16 x i32> zeroinitializer
918 %shift = shl <16 x i8> %a, %splat
926 define <2 x i64> @constant_shift_v2i64(<2 x i64> %a) nounwind {
927 ; SSE2-LABEL: constant_shift_v2i64:
929 ; SSE2-NEXT: movdqa %xmm0, %xmm1
930 ; SSE2-NEXT: paddq %xmm0, %xmm1
931 ; SSE2-NEXT: psllq $7, %xmm0
932 ; SSE2-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
935 ; SSE41-LABEL: constant_shift_v2i64:
937 ; SSE41-NEXT: movdqa %xmm0, %xmm1
938 ; SSE41-NEXT: psllq $7, %xmm1
939 ; SSE41-NEXT: paddq %xmm0, %xmm0
940 ; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[4,5,6,7]
943 ; AVX1-LABEL: constant_shift_v2i64:
945 ; AVX1-NEXT: vpsllq $7, %xmm0, %xmm1
946 ; AVX1-NEXT: vpaddq %xmm0, %xmm0, %xmm0
947 ; AVX1-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[4,5,6,7]
950 ; AVX2-LABEL: constant_shift_v2i64:
952 ; AVX2-NEXT: vpsllvq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
955 ; XOPAVX1-LABEL: constant_shift_v2i64:
957 ; XOPAVX1-NEXT: vpshlq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
960 ; XOPAVX2-LABEL: constant_shift_v2i64:
962 ; XOPAVX2-NEXT: vpsllvq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
965 ; AVX512-LABEL: constant_shift_v2i64:
967 ; AVX512-NEXT: vpsllvq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
970 ; AVX512VL-LABEL: constant_shift_v2i64:
972 ; AVX512VL-NEXT: vpsllvq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
973 ; AVX512VL-NEXT: retq
975 ; X86-SSE-LABEL: constant_shift_v2i64:
977 ; X86-SSE-NEXT: movdqa %xmm0, %xmm1
978 ; X86-SSE-NEXT: paddq %xmm0, %xmm1
979 ; X86-SSE-NEXT: psllq $7, %xmm0
980 ; X86-SSE-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
982 %shift = shl <2 x i64> %a, <i64 1, i64 7>
986 define <4 x i32> @constant_shift_v4i32(<4 x i32> %a) nounwind {
987 ; SSE2-LABEL: constant_shift_v4i32:
989 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,1,3,3]
990 ; SSE2-NEXT: pmuludq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
991 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
992 ; SSE2-NEXT: pmuludq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
993 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
994 ; SSE2-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
997 ; SSE41-LABEL: constant_shift_v4i32:
999 ; SSE41-NEXT: pmulld {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1002 ; AVX1-LABEL: constant_shift_v4i32:
1004 ; AVX1-NEXT: vpmulld {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1007 ; AVX2-LABEL: constant_shift_v4i32:
1009 ; AVX2-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1012 ; XOPAVX1-LABEL: constant_shift_v4i32:
1014 ; XOPAVX1-NEXT: vpshld {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1015 ; XOPAVX1-NEXT: retq
1017 ; XOPAVX2-LABEL: constant_shift_v4i32:
1019 ; XOPAVX2-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1020 ; XOPAVX2-NEXT: retq
1022 ; AVX512-LABEL: constant_shift_v4i32:
1024 ; AVX512-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1027 ; AVX512VL-LABEL: constant_shift_v4i32:
1028 ; AVX512VL: # %bb.0:
1029 ; AVX512VL-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1030 ; AVX512VL-NEXT: retq
1032 ; X86-SSE-LABEL: constant_shift_v4i32:
1034 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,1,3,3]
1035 ; X86-SSE-NEXT: pmuludq {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
1036 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
1037 ; X86-SSE-NEXT: pmuludq {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
1038 ; X86-SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
1039 ; X86-SSE-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
1040 ; X86-SSE-NEXT: retl
1041 %shift = shl <4 x i32> %a, <i32 4, i32 5, i32 6, i32 7>
1042 ret <4 x i32> %shift
1045 define <8 x i16> @constant_shift_v8i16(<8 x i16> %a) nounwind {
1046 ; SSE-LABEL: constant_shift_v8i16:
1048 ; SSE-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # [1,2,4,8,16,32,64,128]
1051 ; AVX-LABEL: constant_shift_v8i16:
1053 ; AVX-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 # [1,2,4,8,16,32,64,128]
1056 ; XOP-LABEL: constant_shift_v8i16:
1058 ; XOP-NEXT: vpshlw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1061 ; AVX512DQ-LABEL: constant_shift_v8i16:
1062 ; AVX512DQ: # %bb.0:
1063 ; AVX512DQ-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 # [1,2,4,8,16,32,64,128]
1064 ; AVX512DQ-NEXT: retq
1066 ; AVX512BW-LABEL: constant_shift_v8i16:
1067 ; AVX512BW: # %bb.0:
1068 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
1069 ; AVX512BW-NEXT: vpmovsxbw {{.*#+}} xmm1 = [0,1,2,3,4,5,6,7]
1070 ; AVX512BW-NEXT: vpsllvw %zmm1, %zmm0, %zmm0
1071 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $zmm0
1072 ; AVX512BW-NEXT: vzeroupper
1073 ; AVX512BW-NEXT: retq
1075 ; AVX512DQVL-LABEL: constant_shift_v8i16:
1076 ; AVX512DQVL: # %bb.0:
1077 ; AVX512DQVL-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 # [1,2,4,8,16,32,64,128]
1078 ; AVX512DQVL-NEXT: retq
1080 ; AVX512BWVL-LABEL: constant_shift_v8i16:
1081 ; AVX512BWVL: # %bb.0:
1082 ; AVX512BWVL-NEXT: vpsllvw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1083 ; AVX512BWVL-NEXT: retq
1085 ; X86-SSE-LABEL: constant_shift_v8i16:
1087 ; X86-SSE-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 # [1,2,4,8,16,32,64,128]
1088 ; X86-SSE-NEXT: retl
1089 %shift = shl <8 x i16> %a, <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>
1090 ret <8 x i16> %shift
1093 define <16 x i8> @constant_shift_v16i8(<16 x i8> %a) nounwind {
1094 ; SSE2-LABEL: constant_shift_v16i8:
1096 ; SSE2-NEXT: movdqa %xmm0, %xmm1
1097 ; SSE2-NEXT: punpckhbw {{.*#+}} xmm1 = xmm1[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
1098 ; SSE2-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1 # [128,64,32,16,8,4,2,1]
1099 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [255,255,255,255,255,255,255,255]
1100 ; SSE2-NEXT: pand %xmm2, %xmm1
1101 ; SSE2-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
1102 ; SSE2-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # [1,2,4,8,16,32,64,128]
1103 ; SSE2-NEXT: pand %xmm2, %xmm0
1104 ; SSE2-NEXT: packuswb %xmm1, %xmm0
1107 ; SSE41-LABEL: constant_shift_v16i8:
1109 ; SSE41-NEXT: movdqa %xmm0, %xmm1
1110 ; SSE41-NEXT: pmaddubsw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1 # [0,2,0,8,0,32,0,128,0,64,0,16,0,4,0,1]
1111 ; SSE41-NEXT: psllw $8, %xmm1
1112 ; SSE41-NEXT: pmaddubsw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 # [1,0,4,0,16,0,64,0,128,0,32,0,8,0,2,0]
1113 ; SSE41-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1114 ; SSE41-NEXT: por %xmm1, %xmm0
1117 ; AVX1-LABEL: constant_shift_v16i8:
1119 ; AVX1-NEXT: vpmaddubsw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm1 # [0,2,0,8,0,32,0,128,0,64,0,16,0,4,0,1]
1120 ; AVX1-NEXT: vpsllw $8, %xmm1, %xmm1
1121 ; AVX1-NEXT: vpmaddubsw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0 # [1,0,4,0,16,0,64,0,128,0,32,0,8,0,2,0]
1122 ; AVX1-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1123 ; AVX1-NEXT: vpor %xmm1, %xmm0, %xmm0
1126 ; AVX2-LABEL: constant_shift_v16i8:
1128 ; AVX2-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
1129 ; AVX2-NEXT: vpmullw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0 # [1,2,4,8,16,32,64,128,128,64,32,16,8,4,2,1]
1130 ; AVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1131 ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1
1132 ; AVX2-NEXT: vpackuswb %xmm1, %xmm0, %xmm0
1133 ; AVX2-NEXT: vzeroupper
1136 ; XOP-LABEL: constant_shift_v16i8:
1138 ; XOP-NEXT: vpshlb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1141 ; AVX512DQ-LABEL: constant_shift_v16i8:
1142 ; AVX512DQ: # %bb.0:
1143 ; AVX512DQ-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
1144 ; AVX512DQ-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %zmm0, %zmm0
1145 ; AVX512DQ-NEXT: vpmovdb %zmm0, %xmm0
1146 ; AVX512DQ-NEXT: vzeroupper
1147 ; AVX512DQ-NEXT: retq
1149 ; AVX512BW-LABEL: constant_shift_v16i8:
1150 ; AVX512BW: # %bb.0:
1151 ; AVX512BW-NEXT: vpmovsxbw {{.*#+}} ymm1 = [0,1,2,3,4,5,6,7,7,6,5,4,3,2,1,0]
1152 ; AVX512BW-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
1153 ; AVX512BW-NEXT: vpsllvw %zmm1, %zmm0, %zmm0
1154 ; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0
1155 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
1156 ; AVX512BW-NEXT: vzeroupper
1157 ; AVX512BW-NEXT: retq
1159 ; AVX512DQVL-LABEL: constant_shift_v16i8:
1160 ; AVX512DQVL: # %bb.0:
1161 ; AVX512DQVL-NEXT: vpmovzxbd {{.*#+}} zmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero,xmm0[2],zero,zero,zero,xmm0[3],zero,zero,zero,xmm0[4],zero,zero,zero,xmm0[5],zero,zero,zero,xmm0[6],zero,zero,zero,xmm0[7],zero,zero,zero,xmm0[8],zero,zero,zero,xmm0[9],zero,zero,zero,xmm0[10],zero,zero,zero,xmm0[11],zero,zero,zero,xmm0[12],zero,zero,zero,xmm0[13],zero,zero,zero,xmm0[14],zero,zero,zero,xmm0[15],zero,zero,zero
1162 ; AVX512DQVL-NEXT: vpsllvd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %zmm0, %zmm0
1163 ; AVX512DQVL-NEXT: vpmovdb %zmm0, %xmm0
1164 ; AVX512DQVL-NEXT: vzeroupper
1165 ; AVX512DQVL-NEXT: retq
1167 ; AVX512BWVL-LABEL: constant_shift_v16i8:
1168 ; AVX512BWVL: # %bb.0:
1169 ; AVX512BWVL-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
1170 ; AVX512BWVL-NEXT: vpsllvw {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1171 ; AVX512BWVL-NEXT: vpmovwb %ymm0, %xmm0
1172 ; AVX512BWVL-NEXT: vzeroupper
1173 ; AVX512BWVL-NEXT: retq
1175 ; X86-SSE-LABEL: constant_shift_v16i8:
1177 ; X86-SSE-NEXT: movdqa %xmm0, %xmm1
1178 ; X86-SSE-NEXT: punpckhbw {{.*#+}} xmm1 = xmm1[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
1179 ; X86-SSE-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 # [128,64,32,16,8,4,2,1]
1180 ; X86-SSE-NEXT: movdqa {{.*#+}} xmm2 = [255,255,255,255,255,255,255,255]
1181 ; X86-SSE-NEXT: pand %xmm2, %xmm1
1182 ; X86-SSE-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
1183 ; X86-SSE-NEXT: pmullw {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 # [1,2,4,8,16,32,64,128]
1184 ; X86-SSE-NEXT: pand %xmm2, %xmm0
1185 ; X86-SSE-NEXT: packuswb %xmm1, %xmm0
1186 ; X86-SSE-NEXT: retl
1187 %shift = shl <16 x i8> %a, <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>
1188 ret <16 x i8> %shift
1192 ; Uniform Constant Shifts
1195 define <2 x i64> @splatconstant_shift_v2i64(<2 x i64> %a) nounwind {
1196 ; SSE-LABEL: splatconstant_shift_v2i64:
1198 ; SSE-NEXT: psllq $7, %xmm0
1201 ; AVX-LABEL: splatconstant_shift_v2i64:
1203 ; AVX-NEXT: vpsllq $7, %xmm0, %xmm0
1206 ; XOP-LABEL: splatconstant_shift_v2i64:
1208 ; XOP-NEXT: vpsllq $7, %xmm0, %xmm0
1211 ; AVX512-LABEL: splatconstant_shift_v2i64:
1213 ; AVX512-NEXT: vpsllq $7, %xmm0, %xmm0
1216 ; AVX512VL-LABEL: splatconstant_shift_v2i64:
1217 ; AVX512VL: # %bb.0:
1218 ; AVX512VL-NEXT: vpsllq $7, %xmm0, %xmm0
1219 ; AVX512VL-NEXT: retq
1221 ; X86-SSE-LABEL: splatconstant_shift_v2i64:
1223 ; X86-SSE-NEXT: psllq $7, %xmm0
1224 ; X86-SSE-NEXT: retl
1225 %shift = shl <2 x i64> %a, <i64 7, i64 7>
1226 ret <2 x i64> %shift
1229 define <4 x i32> @splatconstant_shift_v4i32(<4 x i32> %a) nounwind {
1230 ; SSE-LABEL: splatconstant_shift_v4i32:
1232 ; SSE-NEXT: pslld $5, %xmm0
1235 ; AVX-LABEL: splatconstant_shift_v4i32:
1237 ; AVX-NEXT: vpslld $5, %xmm0, %xmm0
1240 ; XOP-LABEL: splatconstant_shift_v4i32:
1242 ; XOP-NEXT: vpslld $5, %xmm0, %xmm0
1245 ; AVX512-LABEL: splatconstant_shift_v4i32:
1247 ; AVX512-NEXT: vpslld $5, %xmm0, %xmm0
1250 ; AVX512VL-LABEL: splatconstant_shift_v4i32:
1251 ; AVX512VL: # %bb.0:
1252 ; AVX512VL-NEXT: vpslld $5, %xmm0, %xmm0
1253 ; AVX512VL-NEXT: retq
1255 ; X86-SSE-LABEL: splatconstant_shift_v4i32:
1257 ; X86-SSE-NEXT: pslld $5, %xmm0
1258 ; X86-SSE-NEXT: retl
1259 %shift = shl <4 x i32> %a, <i32 5, i32 5, i32 5, i32 5>
1260 ret <4 x i32> %shift
1263 define <8 x i16> @splatconstant_shift_v8i16(<8 x i16> %a) nounwind {
1264 ; SSE-LABEL: splatconstant_shift_v8i16:
1266 ; SSE-NEXT: psllw $3, %xmm0
1269 ; AVX-LABEL: splatconstant_shift_v8i16:
1271 ; AVX-NEXT: vpsllw $3, %xmm0, %xmm0
1274 ; XOP-LABEL: splatconstant_shift_v8i16:
1276 ; XOP-NEXT: vpsllw $3, %xmm0, %xmm0
1279 ; AVX512-LABEL: splatconstant_shift_v8i16:
1281 ; AVX512-NEXT: vpsllw $3, %xmm0, %xmm0
1284 ; AVX512VL-LABEL: splatconstant_shift_v8i16:
1285 ; AVX512VL: # %bb.0:
1286 ; AVX512VL-NEXT: vpsllw $3, %xmm0, %xmm0
1287 ; AVX512VL-NEXT: retq
1289 ; X86-SSE-LABEL: splatconstant_shift_v8i16:
1291 ; X86-SSE-NEXT: psllw $3, %xmm0
1292 ; X86-SSE-NEXT: retl
1293 %shift = shl <8 x i16> %a, <i16 3, i16 3, i16 3, i16 3, i16 3, i16 3, i16 3, i16 3>
1294 ret <8 x i16> %shift
1297 define <16 x i8> @splatconstant_shift_v16i8(<16 x i8> %a) nounwind {
1298 ; SSE-LABEL: splatconstant_shift_v16i8:
1300 ; SSE-NEXT: psllw $3, %xmm0
1301 ; SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1304 ; AVX-LABEL: splatconstant_shift_v16i8:
1306 ; AVX-NEXT: vpsllw $3, %xmm0, %xmm0
1307 ; AVX-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1310 ; XOP-LABEL: splatconstant_shift_v16i8:
1312 ; XOP-NEXT: vpshlb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1315 ; AVX512-LABEL: splatconstant_shift_v16i8:
1317 ; AVX512-NEXT: vpsllw $3, %xmm0, %xmm0
1318 ; AVX512-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1321 ; AVX512VL-LABEL: splatconstant_shift_v16i8:
1322 ; AVX512VL: # %bb.0:
1323 ; AVX512VL-NEXT: vpsllw $3, %xmm0, %xmm0
1324 ; AVX512VL-NEXT: vpandd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to4}, %xmm0, %xmm0
1325 ; AVX512VL-NEXT: retq
1327 ; X86-SSE-LABEL: splatconstant_shift_v16i8:
1329 ; X86-SSE-NEXT: psllw $3, %xmm0
1330 ; X86-SSE-NEXT: pand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
1331 ; X86-SSE-NEXT: retl
1332 %shift = shl <16 x i8> %a, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
1333 ret <16 x i8> %shift