1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefix=SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s --check-prefix=AVX2
5 define void @trunc_shl_7_v4i32_v4i64(<4 x i32> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) {
6 ; SSE2-LABEL: trunc_shl_7_v4i32_v4i64:
8 ; SSE2-NEXT: movaps (%rsi), %xmm0
9 ; SSE2-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],mem[0,2]
10 ; SSE2-NEXT: pslld $7, %xmm0
11 ; SSE2-NEXT: movdqa %xmm0, (%rdi)
14 ; AVX2-LABEL: trunc_shl_7_v4i32_v4i64:
16 ; AVX2-NEXT: vpshufd {{.*#+}} ymm0 = mem[0,2,2,3,4,6,6,7]
17 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
18 ; AVX2-NEXT: vpslld $7, %xmm0, %xmm0
19 ; AVX2-NEXT: vmovdqa %xmm0, (%rdi)
20 ; AVX2-NEXT: vzeroupper
22 %val = load <4 x i64>, <4 x i64> addrspace(1)* %in
23 %shl = shl <4 x i64> %val, <i64 7, i64 7, i64 7, i64 7>
24 %trunc = trunc <4 x i64> %shl to <4 x i32>
25 store <4 x i32> %trunc, <4 x i32> addrspace(1)* %out
29 define <8 x i16> @trunc_shl_15_v8i16_v8i32(<8 x i32> %a) {
30 ; SSE2-LABEL: trunc_shl_15_v8i16_v8i32:
32 ; SSE2-NEXT: pslld $16, %xmm1
33 ; SSE2-NEXT: psrad $16, %xmm1
34 ; SSE2-NEXT: pslld $16, %xmm0
35 ; SSE2-NEXT: psrad $16, %xmm0
36 ; SSE2-NEXT: packssdw %xmm1, %xmm0
37 ; SSE2-NEXT: psllw $15, %xmm0
40 ; AVX2-LABEL: trunc_shl_15_v8i16_v8i32:
42 ; AVX2-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]
43 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,2,3]
44 ; AVX2-NEXT: vpsllw $15, %xmm0, %xmm0
45 ; AVX2-NEXT: vzeroupper
47 %shl = shl <8 x i32> %a, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
48 %conv = trunc <8 x i32> %shl to <8 x i16>
52 define <8 x i16> @trunc_shl_16_v8i16_v8i32(<8 x i32> %a) {
53 ; SSE2-LABEL: trunc_shl_16_v8i16_v8i32:
55 ; SSE2-NEXT: xorps %xmm0, %xmm0
58 ; AVX2-LABEL: trunc_shl_16_v8i16_v8i32:
60 ; AVX2-NEXT: vxorps %xmm0, %xmm0, %xmm0
62 %shl = shl <8 x i32> %a, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
63 %conv = trunc <8 x i32> %shl to <8 x i16>
67 define <8 x i16> @trunc_shl_17_v8i16_v8i32(<8 x i32> %a) {
68 ; SSE2-LABEL: trunc_shl_17_v8i16_v8i32:
70 ; SSE2-NEXT: xorps %xmm0, %xmm0
73 ; AVX2-LABEL: trunc_shl_17_v8i16_v8i32:
75 ; AVX2-NEXT: vxorps %xmm0, %xmm0, %xmm0
77 %shl = shl <8 x i32> %a, <i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17, i32 17>
78 %conv = trunc <8 x i32> %shl to <8 x i16>
82 define void @trunc_shl_31_i32_i64(i32* %out, i64* %in) {
83 ; SSE2-LABEL: trunc_shl_31_i32_i64:
85 ; SSE2-NEXT: movl (%rsi), %eax
86 ; SSE2-NEXT: shll $31, %eax
87 ; SSE2-NEXT: movl %eax, (%rdi)
90 ; AVX2-LABEL: trunc_shl_31_i32_i64:
92 ; AVX2-NEXT: movl (%rsi), %eax
93 ; AVX2-NEXT: shll $31, %eax
94 ; AVX2-NEXT: movl %eax, (%rdi)
96 %val = load i64, i64* %in
97 %shl = shl i64 %val, 31
98 %trunc = trunc i64 %shl to i32
99 store i32 %trunc, i32* %out
103 define void @trunc_shl_32_i32_i64(i32* %out, i64* %in) {
104 ; SSE2-LABEL: trunc_shl_32_i32_i64:
106 ; SSE2-NEXT: movl $0, (%rdi)
109 ; AVX2-LABEL: trunc_shl_32_i32_i64:
111 ; AVX2-NEXT: movl $0, (%rdi)
113 %val = load i64, i64* %in
114 %shl = shl i64 %val, 32
115 %trunc = trunc i64 %shl to i32
116 store i32 %trunc, i32* %out
120 define void @trunc_shl_15_i16_i64(i16* %out, i64* %in) {
121 ; SSE2-LABEL: trunc_shl_15_i16_i64:
123 ; SSE2-NEXT: movl (%rsi), %eax
124 ; SSE2-NEXT: shll $15, %eax
125 ; SSE2-NEXT: movw %ax, (%rdi)
128 ; AVX2-LABEL: trunc_shl_15_i16_i64:
130 ; AVX2-NEXT: movl (%rsi), %eax
131 ; AVX2-NEXT: shll $15, %eax
132 ; AVX2-NEXT: movw %ax, (%rdi)
134 %val = load i64, i64* %in
135 %shl = shl i64 %val, 15
136 %trunc = trunc i64 %shl to i16
137 store i16 %trunc, i16* %out
141 define void @trunc_shl_16_i16_i64(i16* %out, i64* %in) {
142 ; SSE2-LABEL: trunc_shl_16_i16_i64:
144 ; SSE2-NEXT: movw $0, (%rdi)
147 ; AVX2-LABEL: trunc_shl_16_i16_i64:
149 ; AVX2-NEXT: movw $0, (%rdi)
151 %val = load i64, i64* %in
152 %shl = shl i64 %val, 16
153 %trunc = trunc i64 %shl to i16
154 store i16 %trunc, i16* %out
158 define void @trunc_shl_7_i8_i64(i8* %out, i64* %in) {
159 ; SSE2-LABEL: trunc_shl_7_i8_i64:
161 ; SSE2-NEXT: movb (%rsi), %al
162 ; SSE2-NEXT: shlb $7, %al
163 ; SSE2-NEXT: movb %al, (%rdi)
166 ; AVX2-LABEL: trunc_shl_7_i8_i64:
168 ; AVX2-NEXT: movb (%rsi), %al
169 ; AVX2-NEXT: shlb $7, %al
170 ; AVX2-NEXT: movb %al, (%rdi)
172 %val = load i64, i64* %in
173 %shl = shl i64 %val, 7
174 %trunc = trunc i64 %shl to i8
175 store i8 %trunc, i8* %out
179 define void @trunc_shl_8_i8_i64(i8* %out, i64* %in) {
180 ; SSE2-LABEL: trunc_shl_8_i8_i64:
182 ; SSE2-NEXT: movb $0, (%rdi)
185 ; AVX2-LABEL: trunc_shl_8_i8_i64:
187 ; AVX2-NEXT: movb $0, (%rdi)
189 %val = load i64, i64* %in
190 %shl = shl i64 %val, 8
191 %trunc = trunc i64 %shl to i8
192 store i8 %trunc, i8* %out