1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=X32,X32-SLOW
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx2,+fast-variable-shuffle | FileCheck %s --check-prefixes=X32,X32-FAST
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=X64,X64-SLOW
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2,+fast-variable-shuffle | FileCheck %s --check-prefixes=X64,X64-FAST
7 define <4 x i32> @trunc4(<4 x i64> %A) nounwind {
8 ; X32-SLOW-LABEL: trunc4:
10 ; X32-SLOW-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[0,2,2,3,4,6,6,7]
11 ; X32-SLOW-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[0,2,2,3]
12 ; X32-SLOW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
13 ; X32-SLOW-NEXT: vzeroupper
16 ; X32-FAST-LABEL: trunc4:
18 ; X32-FAST-NEXT: vmovaps {{.*#+}} ymm1 = [0,2,4,6,4,6,6,7]
19 ; X32-FAST-NEXT: vpermps %ymm0, %ymm1, %ymm0
20 ; X32-FAST-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
21 ; X32-FAST-NEXT: vzeroupper
24 ; X64-SLOW-LABEL: trunc4:
26 ; X64-SLOW-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[0,2,2,3,4,6,6,7]
27 ; X64-SLOW-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[0,2,2,3]
28 ; X64-SLOW-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
29 ; X64-SLOW-NEXT: vzeroupper
32 ; X64-FAST-LABEL: trunc4:
34 ; X64-FAST-NEXT: vmovaps {{.*#+}} ymm1 = [0,2,4,6,4,6,6,7]
35 ; X64-FAST-NEXT: vpermps %ymm0, %ymm1, %ymm0
36 ; X64-FAST-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
37 ; X64-FAST-NEXT: vzeroupper
39 %B = trunc <4 x i64> %A to <4 x i32>
43 define <8 x i16> @trunc8(<8 x i32> %A) nounwind {
46 ; X32-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15,16,17,20,21,24,25,28,29,24,25,28,29,28,29,30,31]
47 ; X32-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
48 ; X32-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
49 ; X32-NEXT: vzeroupper
54 ; X64-NEXT: vpshufb {{.*#+}} ymm0 = ymm0[0,1,4,5,8,9,12,13,8,9,12,13,12,13,14,15,16,17,20,21,24,25,28,29,24,25,28,29,28,29,30,31]
55 ; X64-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
56 ; X64-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
57 ; X64-NEXT: vzeroupper
59 %B = trunc <8 x i32> %A to <8 x i16>
63 define <4 x i64> @sext4(<4 x i32> %A) nounwind {
66 ; X32-NEXT: vpmovsxdq %xmm0, %ymm0
71 ; X64-NEXT: vpmovsxdq %xmm0, %ymm0
73 %B = sext <4 x i32> %A to <4 x i64>
77 define <8 x i32> @sext8(<8 x i16> %A) nounwind {
80 ; X32-NEXT: vpmovsxwd %xmm0, %ymm0
85 ; X64-NEXT: vpmovsxwd %xmm0, %ymm0
87 %B = sext <8 x i16> %A to <8 x i32>
91 define <4 x i64> @zext4(<4 x i32> %A) nounwind {
94 ; X32-NEXT: vpmovzxdq {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
99 ; X64-NEXT: vpmovzxdq {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero
101 %B = zext <4 x i32> %A to <4 x i64>
105 define <8 x i32> @zext8(<8 x i16> %A) nounwind {
108 ; X32-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
113 ; X64-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
115 %B = zext <8 x i16> %A to <8 x i32>
119 define <8 x i32> @zext_8i8_8i32(<8 x i8> %A) nounwind {
120 ; X32-LABEL: zext_8i8_8i32:
122 ; X32-NEXT: vpand {{\.LCPI.*}}, %xmm0, %xmm0
123 ; X32-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
126 ; X64-LABEL: zext_8i8_8i32:
128 ; X64-NEXT: vpand {{.*}}(%rip), %xmm0, %xmm0
129 ; X64-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
131 %B = zext <8 x i8> %A to <8 x i32>
135 define <16 x i16> @zext_16i8_16i16(<16 x i8> %z) {
136 ; X32-LABEL: zext_16i8_16i16:
138 ; X32-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
141 ; X64-LABEL: zext_16i8_16i16:
143 ; X64-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
145 %t = zext <16 x i8> %z to <16 x i16>
149 define <16 x i16> @sext_16i8_16i16(<16 x i8> %z) {
150 ; X32-LABEL: sext_16i8_16i16:
152 ; X32-NEXT: vpmovsxbw %xmm0, %ymm0
155 ; X64-LABEL: sext_16i8_16i16:
157 ; X64-NEXT: vpmovsxbw %xmm0, %ymm0
159 %t = sext <16 x i8> %z to <16 x i16>
163 define <16 x i8> @trunc_16i16_16i8(<16 x i16> %z) {
164 ; X32-LABEL: trunc_16i16_16i8:
166 ; X32-NEXT: vpand {{\.LCPI.*}}, %ymm0, %ymm0
167 ; X32-NEXT: vextracti128 $1, %ymm0, %xmm1
168 ; X32-NEXT: vpackuswb %xmm1, %xmm0, %xmm0
169 ; X32-NEXT: vzeroupper
172 ; X64-LABEL: trunc_16i16_16i8:
174 ; X64-NEXT: vpand {{.*}}(%rip), %ymm0, %ymm0
175 ; X64-NEXT: vextracti128 $1, %ymm0, %xmm1
176 ; X64-NEXT: vpackuswb %xmm1, %xmm0, %xmm0
177 ; X64-NEXT: vzeroupper
179 %t = trunc <16 x i16> %z to <16 x i8>
183 define <4 x i64> @load_sext_test1(<4 x i32> *%ptr) {
184 ; X32-LABEL: load_sext_test1:
186 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
187 ; X32-NEXT: vpmovsxdq (%eax), %ymm0
190 ; X64-LABEL: load_sext_test1:
192 ; X64-NEXT: vpmovsxdq (%rdi), %ymm0
194 %X = load <4 x i32>, <4 x i32>* %ptr
195 %Y = sext <4 x i32> %X to <4 x i64>
199 define <4 x i64> @load_sext_test2(<4 x i8> *%ptr) {
200 ; X32-LABEL: load_sext_test2:
202 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
203 ; X32-NEXT: vpmovsxbq (%eax), %ymm0
206 ; X64-LABEL: load_sext_test2:
208 ; X64-NEXT: vpmovsxbq (%rdi), %ymm0
210 %X = load <4 x i8>, <4 x i8>* %ptr
211 %Y = sext <4 x i8> %X to <4 x i64>
215 define <4 x i64> @load_sext_test3(<4 x i16> *%ptr) {
216 ; X32-LABEL: load_sext_test3:
218 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
219 ; X32-NEXT: vpmovsxwq (%eax), %ymm0
222 ; X64-LABEL: load_sext_test3:
224 ; X64-NEXT: vpmovsxwq (%rdi), %ymm0
226 %X = load <4 x i16>, <4 x i16>* %ptr
227 %Y = sext <4 x i16> %X to <4 x i64>
231 define <8 x i32> @load_sext_test4(<8 x i16> *%ptr) {
232 ; X32-LABEL: load_sext_test4:
234 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
235 ; X32-NEXT: vpmovsxwd (%eax), %ymm0
238 ; X64-LABEL: load_sext_test4:
240 ; X64-NEXT: vpmovsxwd (%rdi), %ymm0
242 %X = load <8 x i16>, <8 x i16>* %ptr
243 %Y = sext <8 x i16> %X to <8 x i32>
247 define <8 x i32> @load_sext_test5(<8 x i8> *%ptr) {
248 ; X32-LABEL: load_sext_test5:
250 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
251 ; X32-NEXT: vpmovsxbd (%eax), %ymm0
254 ; X64-LABEL: load_sext_test5:
256 ; X64-NEXT: vpmovsxbd (%rdi), %ymm0
258 %X = load <8 x i8>, <8 x i8>* %ptr
259 %Y = sext <8 x i8> %X to <8 x i32>