1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f | FileCheck %s --check-prefixes=AVX512,AVX512F
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512vl | FileCheck %s --check-prefixes=AVX512,AVX512VL
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512bw | FileCheck %s --check-prefixes=AVX512,AVX512BW,AVX512BWNOVL
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512vl,avx512bw | FileCheck %s --check-prefixes=AVX512,AVX512VL,AVX512BWVL
7 define void @truncstore_v8i64_v8i32(<8 x i64> %x, <8 x i32>* %p, <8 x i32> %mask) {
8 ; AVX512F-LABEL: truncstore_v8i64_v8i32:
10 ; AVX512F-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
11 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k1
12 ; AVX512F-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
13 ; AVX512F-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
14 ; AVX512F-NEXT: vpmovqd %zmm0, (%rdi) {%k1}
15 ; AVX512F-NEXT: vzeroupper
18 ; AVX512VL-LABEL: truncstore_v8i64_v8i32:
20 ; AVX512VL-NEXT: vptestmd %ymm1, %ymm1, %k1
21 ; AVX512VL-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
22 ; AVX512VL-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
23 ; AVX512VL-NEXT: vpmovqd %zmm0, (%rdi) {%k1}
24 ; AVX512VL-NEXT: vzeroupper
27 ; AVX512BW-LABEL: truncstore_v8i64_v8i32:
29 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
30 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k1
31 ; AVX512BW-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
32 ; AVX512BW-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
33 ; AVX512BW-NEXT: vpmovqd %zmm0, (%rdi) {%k1}
34 ; AVX512BW-NEXT: vzeroupper
36 %a = icmp ne <8 x i32> %mask, zeroinitializer
37 %b = icmp slt <8 x i64> %x, <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
38 %c = select <8 x i1> %b, <8 x i64> %x, <8 x i64> <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
39 %d = icmp sgt <8 x i64> %c, <i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648>
40 %e = select <8 x i1> %d, <8 x i64> %c, <8 x i64> <i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648>
41 %f = trunc <8 x i64> %e to <8 x i32>
42 call void @llvm.masked.store.v8i32.p0v8i32(<8 x i32> %f, <8 x i32>* %p, i32 1, <8 x i1> %a)
46 define void @truncstore_v8i64_v8i16(<8 x i64> %x, <8 x i16>* %p, <8 x i32> %mask) {
47 ; AVX512F-LABEL: truncstore_v8i64_v8i16:
49 ; AVX512F-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
50 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
51 ; AVX512F-NEXT: vpmovsqw %zmm0, %xmm0
52 ; AVX512F-NEXT: kmovw %k0, %eax
53 ; AVX512F-NEXT: testb $1, %al
54 ; AVX512F-NEXT: je .LBB1_2
55 ; AVX512F-NEXT: # %bb.1: # %cond.store
56 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
57 ; AVX512F-NEXT: .LBB1_2: # %else
58 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
59 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
60 ; AVX512F-NEXT: kmovw %k0, %eax
61 ; AVX512F-NEXT: testb $1, %al
62 ; AVX512F-NEXT: je .LBB1_4
63 ; AVX512F-NEXT: # %bb.3: # %cond.store1
64 ; AVX512F-NEXT: vpextrw $1, %xmm0, 2(%rdi)
65 ; AVX512F-NEXT: .LBB1_4: # %else2
66 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
67 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
68 ; AVX512F-NEXT: kmovw %k0, %eax
69 ; AVX512F-NEXT: testb $1, %al
70 ; AVX512F-NEXT: je .LBB1_6
71 ; AVX512F-NEXT: # %bb.5: # %cond.store3
72 ; AVX512F-NEXT: vpextrw $2, %xmm0, 4(%rdi)
73 ; AVX512F-NEXT: .LBB1_6: # %else4
74 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
75 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
76 ; AVX512F-NEXT: kmovw %k0, %eax
77 ; AVX512F-NEXT: testb $1, %al
78 ; AVX512F-NEXT: je .LBB1_8
79 ; AVX512F-NEXT: # %bb.7: # %cond.store5
80 ; AVX512F-NEXT: vpextrw $3, %xmm0, 6(%rdi)
81 ; AVX512F-NEXT: .LBB1_8: # %else6
82 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
83 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
84 ; AVX512F-NEXT: kmovw %k0, %eax
85 ; AVX512F-NEXT: testb $1, %al
86 ; AVX512F-NEXT: je .LBB1_10
87 ; AVX512F-NEXT: # %bb.9: # %cond.store7
88 ; AVX512F-NEXT: vpextrw $4, %xmm0, 8(%rdi)
89 ; AVX512F-NEXT: .LBB1_10: # %else8
90 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
91 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
92 ; AVX512F-NEXT: kmovw %k0, %eax
93 ; AVX512F-NEXT: testb $1, %al
94 ; AVX512F-NEXT: je .LBB1_12
95 ; AVX512F-NEXT: # %bb.11: # %cond.store9
96 ; AVX512F-NEXT: vpextrw $5, %xmm0, 10(%rdi)
97 ; AVX512F-NEXT: .LBB1_12: # %else10
98 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
99 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
100 ; AVX512F-NEXT: kmovw %k0, %eax
101 ; AVX512F-NEXT: testb $1, %al
102 ; AVX512F-NEXT: je .LBB1_14
103 ; AVX512F-NEXT: # %bb.13: # %cond.store11
104 ; AVX512F-NEXT: vpextrw $6, %xmm0, 12(%rdi)
105 ; AVX512F-NEXT: .LBB1_14: # %else12
106 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
107 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
108 ; AVX512F-NEXT: kmovw %k0, %eax
109 ; AVX512F-NEXT: testb $1, %al
110 ; AVX512F-NEXT: je .LBB1_16
111 ; AVX512F-NEXT: # %bb.15: # %cond.store13
112 ; AVX512F-NEXT: vpextrw $7, %xmm0, 14(%rdi)
113 ; AVX512F-NEXT: .LBB1_16: # %else14
114 ; AVX512F-NEXT: vzeroupper
117 ; AVX512BW-LABEL: truncstore_v8i64_v8i16:
119 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
120 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k1
121 ; AVX512BW-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
122 ; AVX512BW-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
123 ; AVX512BW-NEXT: vpmovqw %zmm0, (%rdi) {%k1}
124 ; AVX512BW-NEXT: vzeroupper
125 ; AVX512BW-NEXT: retq
127 ; AVX512BWVL-LABEL: truncstore_v8i64_v8i16:
128 ; AVX512BWVL: # %bb.0:
129 ; AVX512BWVL-NEXT: vptestmd %ymm1, %ymm1, %k1
130 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
131 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
132 ; AVX512BWVL-NEXT: vpmovqw %zmm0, (%rdi) {%k1}
133 ; AVX512BWVL-NEXT: vzeroupper
134 ; AVX512BWVL-NEXT: retq
135 %a = icmp ne <8 x i32> %mask, zeroinitializer
136 %b = icmp slt <8 x i64> %x, <i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767>
137 %c = select <8 x i1> %b, <8 x i64> %x, <8 x i64> <i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767, i64 32767>
138 %d = icmp sgt <8 x i64> %c, <i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768>
139 %e = select <8 x i1> %d, <8 x i64> %c, <8 x i64> <i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768, i64 -32768>
140 %f = trunc <8 x i64> %e to <8 x i16>
141 call void @llvm.masked.store.v8i16.p0v8i16(<8 x i16> %f, <8 x i16>* %p, i32 1, <8 x i1> %a)
145 define void @truncstore_v8i64_v8i8(<8 x i64> %x, <8 x i8>* %p, <8 x i32> %mask) {
146 ; AVX512F-LABEL: truncstore_v8i64_v8i8:
148 ; AVX512F-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
149 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
150 ; AVX512F-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
151 ; AVX512F-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
152 ; AVX512F-NEXT: vpmovqw %zmm0, %xmm0
153 ; AVX512F-NEXT: kmovw %k0, %eax
154 ; AVX512F-NEXT: testb $1, %al
155 ; AVX512F-NEXT: je .LBB2_2
156 ; AVX512F-NEXT: # %bb.1: # %cond.store
157 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
158 ; AVX512F-NEXT: .LBB2_2: # %else
159 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
160 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
161 ; AVX512F-NEXT: kmovw %k0, %eax
162 ; AVX512F-NEXT: testb $1, %al
163 ; AVX512F-NEXT: je .LBB2_4
164 ; AVX512F-NEXT: # %bb.3: # %cond.store1
165 ; AVX512F-NEXT: vpextrb $2, %xmm0, 1(%rdi)
166 ; AVX512F-NEXT: .LBB2_4: # %else2
167 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
168 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
169 ; AVX512F-NEXT: kmovw %k0, %eax
170 ; AVX512F-NEXT: testb $1, %al
171 ; AVX512F-NEXT: je .LBB2_6
172 ; AVX512F-NEXT: # %bb.5: # %cond.store3
173 ; AVX512F-NEXT: vpextrb $4, %xmm0, 2(%rdi)
174 ; AVX512F-NEXT: .LBB2_6: # %else4
175 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
176 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
177 ; AVX512F-NEXT: kmovw %k0, %eax
178 ; AVX512F-NEXT: testb $1, %al
179 ; AVX512F-NEXT: je .LBB2_8
180 ; AVX512F-NEXT: # %bb.7: # %cond.store5
181 ; AVX512F-NEXT: vpextrb $6, %xmm0, 3(%rdi)
182 ; AVX512F-NEXT: .LBB2_8: # %else6
183 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
184 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
185 ; AVX512F-NEXT: kmovw %k0, %eax
186 ; AVX512F-NEXT: testb $1, %al
187 ; AVX512F-NEXT: je .LBB2_10
188 ; AVX512F-NEXT: # %bb.9: # %cond.store7
189 ; AVX512F-NEXT: vpextrb $8, %xmm0, 4(%rdi)
190 ; AVX512F-NEXT: .LBB2_10: # %else8
191 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
192 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
193 ; AVX512F-NEXT: kmovw %k0, %eax
194 ; AVX512F-NEXT: testb $1, %al
195 ; AVX512F-NEXT: je .LBB2_12
196 ; AVX512F-NEXT: # %bb.11: # %cond.store9
197 ; AVX512F-NEXT: vpextrb $10, %xmm0, 5(%rdi)
198 ; AVX512F-NEXT: .LBB2_12: # %else10
199 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
200 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
201 ; AVX512F-NEXT: kmovw %k0, %eax
202 ; AVX512F-NEXT: testb $1, %al
203 ; AVX512F-NEXT: je .LBB2_14
204 ; AVX512F-NEXT: # %bb.13: # %cond.store11
205 ; AVX512F-NEXT: vpextrb $12, %xmm0, 6(%rdi)
206 ; AVX512F-NEXT: .LBB2_14: # %else12
207 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
208 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
209 ; AVX512F-NEXT: kmovw %k0, %eax
210 ; AVX512F-NEXT: testb $1, %al
211 ; AVX512F-NEXT: je .LBB2_16
212 ; AVX512F-NEXT: # %bb.15: # %cond.store13
213 ; AVX512F-NEXT: vpextrb $14, %xmm0, 7(%rdi)
214 ; AVX512F-NEXT: .LBB2_16: # %else14
215 ; AVX512F-NEXT: vzeroupper
218 ; AVX512BW-LABEL: truncstore_v8i64_v8i8:
220 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
221 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k1
222 ; AVX512BW-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
223 ; AVX512BW-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
224 ; AVX512BW-NEXT: vpmovqb %zmm0, (%rdi) {%k1}
225 ; AVX512BW-NEXT: vzeroupper
226 ; AVX512BW-NEXT: retq
228 ; AVX512BWVL-LABEL: truncstore_v8i64_v8i8:
229 ; AVX512BWVL: # %bb.0:
230 ; AVX512BWVL-NEXT: vptestmd %ymm1, %ymm1, %k1
231 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
232 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip){1to8}, %zmm0, %zmm0
233 ; AVX512BWVL-NEXT: vpmovqb %zmm0, (%rdi) {%k1}
234 ; AVX512BWVL-NEXT: vzeroupper
235 ; AVX512BWVL-NEXT: retq
236 %a = icmp ne <8 x i32> %mask, zeroinitializer
237 %b = icmp slt <8 x i64> %x, <i64 127, i64 127, i64 127, i64 127, i64 127, i64 127, i64 127, i64 127>
238 %c = select <8 x i1> %b, <8 x i64> %x, <8 x i64> <i64 127, i64 127, i64 127, i64 127, i64 127, i64 127, i64 127, i64 127>
239 %d = icmp sgt <8 x i64> %c, <i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128>
240 %e = select <8 x i1> %d, <8 x i64> %c, <8 x i64> <i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128, i64 -128>
241 %f = trunc <8 x i64> %e to <8 x i8>
242 call void @llvm.masked.store.v8i8.p0v8i8(<8 x i8> %f, <8 x i8>* %p, i32 1, <8 x i1> %a)
246 define void @truncstore_v4i64_v4i32(<4 x i64> %x, <4 x i32>* %p, <4 x i32> %mask) {
247 ; AVX512F-LABEL: truncstore_v4i64_v4i32:
249 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
250 ; AVX512F-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
251 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
252 ; AVX512F-NEXT: kshiftlw $12, %k0, %k0
253 ; AVX512F-NEXT: kshiftrw $12, %k0, %k1
254 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm1 = [2147483647,2147483647,2147483647,2147483647]
255 ; AVX512F-NEXT: vpminsq %zmm1, %zmm0, %zmm0
256 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm1 = [18446744071562067968,18446744071562067968,18446744071562067968,18446744071562067968]
257 ; AVX512F-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
258 ; AVX512F-NEXT: vpmovqd %zmm0, %ymm0
259 ; AVX512F-NEXT: vmovdqu32 %zmm0, (%rdi) {%k1}
260 ; AVX512F-NEXT: vzeroupper
263 ; AVX512VL-LABEL: truncstore_v4i64_v4i32:
265 ; AVX512VL-NEXT: vptestmd %xmm1, %xmm1, %k1
266 ; AVX512VL-NEXT: vpminsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
267 ; AVX512VL-NEXT: vpmaxsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
268 ; AVX512VL-NEXT: vpmovqd %ymm0, (%rdi) {%k1}
269 ; AVX512VL-NEXT: vzeroupper
270 ; AVX512VL-NEXT: retq
272 ; AVX512BW-LABEL: truncstore_v4i64_v4i32:
274 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
275 ; AVX512BW-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
276 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
277 ; AVX512BW-NEXT: kshiftlw $12, %k0, %k0
278 ; AVX512BW-NEXT: kshiftrw $12, %k0, %k1
279 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [2147483647,2147483647,2147483647,2147483647]
280 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
281 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [18446744071562067968,18446744071562067968,18446744071562067968,18446744071562067968]
282 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
283 ; AVX512BW-NEXT: vpmovqd %zmm0, %ymm0
284 ; AVX512BW-NEXT: vmovdqu32 %zmm0, (%rdi) {%k1}
285 ; AVX512BW-NEXT: vzeroupper
286 ; AVX512BW-NEXT: retq
287 %a = icmp ne <4 x i32> %mask, zeroinitializer
288 %b = icmp slt <4 x i64> %x, <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
289 %c = select <4 x i1> %b, <4 x i64> %x, <4 x i64> <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
290 %d = icmp sgt <4 x i64> %c, <i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648>
291 %e = select <4 x i1> %d, <4 x i64> %c, <4 x i64> <i64 -2147483648, i64 -2147483648, i64 -2147483648, i64 -2147483648>
292 %f = trunc <4 x i64> %e to <4 x i32>
293 call void @llvm.masked.store.v4i32.p0v4i32(<4 x i32> %f, <4 x i32>* %p, i32 1, <4 x i1> %a)
297 define void @truncstore_v4i64_v4i16(<4 x i64> %x, <4 x i16>* %p, <4 x i32> %mask) {
298 ; AVX512F-LABEL: truncstore_v4i64_v4i16:
300 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
301 ; AVX512F-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
302 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
303 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm2 = [32767,32767,32767,32767]
304 ; AVX512F-NEXT: vpminsq %zmm2, %zmm0, %zmm0
305 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm2 = [18446744073709518848,18446744073709518848,18446744073709518848,18446744073709518848]
306 ; AVX512F-NEXT: vpmaxsq %zmm2, %zmm0, %zmm0
307 ; AVX512F-NEXT: vpmovqd %zmm0, %ymm0
308 ; AVX512F-NEXT: kmovw %k0, %eax
309 ; AVX512F-NEXT: testb $1, %al
310 ; AVX512F-NEXT: je .LBB4_2
311 ; AVX512F-NEXT: # %bb.1: # %cond.store
312 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
313 ; AVX512F-NEXT: .LBB4_2: # %else
314 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
315 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
316 ; AVX512F-NEXT: kmovw %k0, %eax
317 ; AVX512F-NEXT: testb $1, %al
318 ; AVX512F-NEXT: je .LBB4_4
319 ; AVX512F-NEXT: # %bb.3: # %cond.store1
320 ; AVX512F-NEXT: vpextrw $2, %xmm0, 2(%rdi)
321 ; AVX512F-NEXT: .LBB4_4: # %else2
322 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
323 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
324 ; AVX512F-NEXT: kmovw %k0, %eax
325 ; AVX512F-NEXT: testb $1, %al
326 ; AVX512F-NEXT: je .LBB4_6
327 ; AVX512F-NEXT: # %bb.5: # %cond.store3
328 ; AVX512F-NEXT: vpextrw $4, %xmm0, 4(%rdi)
329 ; AVX512F-NEXT: .LBB4_6: # %else4
330 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
331 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
332 ; AVX512F-NEXT: kmovw %k0, %eax
333 ; AVX512F-NEXT: testb $1, %al
334 ; AVX512F-NEXT: je .LBB4_8
335 ; AVX512F-NEXT: # %bb.7: # %cond.store5
336 ; AVX512F-NEXT: vpextrw $6, %xmm0, 6(%rdi)
337 ; AVX512F-NEXT: .LBB4_8: # %else6
338 ; AVX512F-NEXT: vzeroupper
341 ; AVX512BW-LABEL: truncstore_v4i64_v4i16:
343 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
344 ; AVX512BW-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
345 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
346 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [32767,32767,32767,32767]
347 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
348 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [18446744073709518848,18446744073709518848,18446744073709518848,18446744073709518848]
349 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
350 ; AVX512BW-NEXT: vpmovqd %zmm0, %ymm0
351 ; AVX512BW-NEXT: vpackssdw %xmm0, %xmm0, %xmm0
352 ; AVX512BW-NEXT: kshiftld $28, %k0, %k0
353 ; AVX512BW-NEXT: kshiftrd $28, %k0, %k1
354 ; AVX512BW-NEXT: vmovdqu16 %zmm0, (%rdi) {%k1}
355 ; AVX512BW-NEXT: vzeroupper
356 ; AVX512BW-NEXT: retq
358 ; AVX512BWVL-LABEL: truncstore_v4i64_v4i16:
359 ; AVX512BWVL: # %bb.0:
360 ; AVX512BWVL-NEXT: vptestmd %xmm1, %xmm1, %k1
361 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
362 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
363 ; AVX512BWVL-NEXT: vpmovqw %ymm0, (%rdi) {%k1}
364 ; AVX512BWVL-NEXT: vzeroupper
365 ; AVX512BWVL-NEXT: retq
366 %a = icmp ne <4 x i32> %mask, zeroinitializer
367 %b = icmp slt <4 x i64> %x, <i64 32767, i64 32767, i64 32767, i64 32767>
368 %c = select <4 x i1> %b, <4 x i64> %x, <4 x i64> <i64 32767, i64 32767, i64 32767, i64 32767>
369 %d = icmp sgt <4 x i64> %c, <i64 -32768, i64 -32768, i64 -32768, i64 -32768>
370 %e = select <4 x i1> %d, <4 x i64> %c, <4 x i64> <i64 -32768, i64 -32768, i64 -32768, i64 -32768>
371 %f = trunc <4 x i64> %e to <4 x i16>
372 call void @llvm.masked.store.v4i16.p0v4i16(<4 x i16> %f, <4 x i16>* %p, i32 1, <4 x i1> %a)
376 define void @truncstore_v4i64_v4i8(<4 x i64> %x, <4 x i8>* %p, <4 x i32> %mask) {
377 ; AVX512F-LABEL: truncstore_v4i64_v4i8:
379 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
380 ; AVX512F-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
381 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
382 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm2 = [127,127,127,127]
383 ; AVX512F-NEXT: vpminsq %zmm2, %zmm0, %zmm0
384 ; AVX512F-NEXT: vpbroadcastq {{.*#+}} ymm2 = [18446744073709551488,18446744073709551488,18446744073709551488,18446744073709551488]
385 ; AVX512F-NEXT: vpmaxsq %zmm2, %zmm0, %zmm0
386 ; AVX512F-NEXT: vpmovqd %zmm0, %ymm0
387 ; AVX512F-NEXT: kmovw %k0, %eax
388 ; AVX512F-NEXT: testb $1, %al
389 ; AVX512F-NEXT: je .LBB5_2
390 ; AVX512F-NEXT: # %bb.1: # %cond.store
391 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
392 ; AVX512F-NEXT: .LBB5_2: # %else
393 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
394 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
395 ; AVX512F-NEXT: kmovw %k0, %eax
396 ; AVX512F-NEXT: testb $1, %al
397 ; AVX512F-NEXT: je .LBB5_4
398 ; AVX512F-NEXT: # %bb.3: # %cond.store1
399 ; AVX512F-NEXT: vpextrb $4, %xmm0, 1(%rdi)
400 ; AVX512F-NEXT: .LBB5_4: # %else2
401 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
402 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
403 ; AVX512F-NEXT: kmovw %k0, %eax
404 ; AVX512F-NEXT: testb $1, %al
405 ; AVX512F-NEXT: je .LBB5_6
406 ; AVX512F-NEXT: # %bb.5: # %cond.store3
407 ; AVX512F-NEXT: vpextrb $8, %xmm0, 2(%rdi)
408 ; AVX512F-NEXT: .LBB5_6: # %else4
409 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
410 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
411 ; AVX512F-NEXT: kmovw %k0, %eax
412 ; AVX512F-NEXT: testb $1, %al
413 ; AVX512F-NEXT: je .LBB5_8
414 ; AVX512F-NEXT: # %bb.7: # %cond.store5
415 ; AVX512F-NEXT: vpextrb $12, %xmm0, 3(%rdi)
416 ; AVX512F-NEXT: .LBB5_8: # %else6
417 ; AVX512F-NEXT: vzeroupper
420 ; AVX512BW-LABEL: truncstore_v4i64_v4i8:
422 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
423 ; AVX512BW-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
424 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
425 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [127,127,127,127]
426 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
427 ; AVX512BW-NEXT: vpbroadcastq {{.*#+}} ymm1 = [18446744073709551488,18446744073709551488,18446744073709551488,18446744073709551488]
428 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
429 ; AVX512BW-NEXT: vpmovqd %zmm0, %ymm0
430 ; AVX512BW-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u]
431 ; AVX512BW-NEXT: kshiftlq $60, %k0, %k0
432 ; AVX512BW-NEXT: kshiftrq $60, %k0, %k1
433 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
434 ; AVX512BW-NEXT: vzeroupper
435 ; AVX512BW-NEXT: retq
437 ; AVX512BWVL-LABEL: truncstore_v4i64_v4i8:
438 ; AVX512BWVL: # %bb.0:
439 ; AVX512BWVL-NEXT: vptestmd %xmm1, %xmm1, %k1
440 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
441 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip){1to4}, %ymm0, %ymm0
442 ; AVX512BWVL-NEXT: vpmovqb %ymm0, (%rdi) {%k1}
443 ; AVX512BWVL-NEXT: vzeroupper
444 ; AVX512BWVL-NEXT: retq
445 %a = icmp ne <4 x i32> %mask, zeroinitializer
446 %b = icmp slt <4 x i64> %x, <i64 127, i64 127, i64 127, i64 127>
447 %c = select <4 x i1> %b, <4 x i64> %x, <4 x i64> <i64 127, i64 127, i64 127, i64 127>
448 %d = icmp sgt <4 x i64> %c, <i64 -128, i64 -128, i64 -128, i64 -128>
449 %e = select <4 x i1> %d, <4 x i64> %c, <4 x i64> <i64 -128, i64 -128, i64 -128, i64 -128>
450 %f = trunc <4 x i64> %e to <4 x i8>
451 call void @llvm.masked.store.v4i8.p0v4i8(<4 x i8> %f, <4 x i8>* %p, i32 1, <4 x i1> %a)
455 define void @truncstore_v2i64_v2i32(<2 x i64> %x, <2 x i32>* %p, <2 x i64> %mask) {
456 ; AVX512F-LABEL: truncstore_v2i64_v2i32:
458 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
459 ; AVX512F-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
460 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
461 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm1 = [2147483647,2147483647]
462 ; AVX512F-NEXT: vpminsq %zmm1, %zmm0, %zmm0
463 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm1 = [18446744071562067968,18446744071562067968]
464 ; AVX512F-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
465 ; AVX512F-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
466 ; AVX512F-NEXT: kshiftlw $14, %k0, %k0
467 ; AVX512F-NEXT: kshiftrw $14, %k0, %k1
468 ; AVX512F-NEXT: vmovdqu32 %zmm0, (%rdi) {%k1}
469 ; AVX512F-NEXT: vzeroupper
472 ; AVX512VL-LABEL: truncstore_v2i64_v2i32:
474 ; AVX512VL-NEXT: vptestmq %xmm1, %xmm1, %k1
475 ; AVX512VL-NEXT: vpminsq {{.*}}(%rip), %xmm0, %xmm0
476 ; AVX512VL-NEXT: vpmaxsq {{.*}}(%rip), %xmm0, %xmm0
477 ; AVX512VL-NEXT: vpmovqd %xmm0, (%rdi) {%k1}
478 ; AVX512VL-NEXT: retq
480 ; AVX512BW-LABEL: truncstore_v2i64_v2i32:
482 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
483 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
484 ; AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k0
485 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [2147483647,2147483647]
486 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
487 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [18446744071562067968,18446744071562067968]
488 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
489 ; AVX512BW-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
490 ; AVX512BW-NEXT: kshiftlw $14, %k0, %k0
491 ; AVX512BW-NEXT: kshiftrw $14, %k0, %k1
492 ; AVX512BW-NEXT: vmovdqu32 %zmm0, (%rdi) {%k1}
493 ; AVX512BW-NEXT: vzeroupper
494 ; AVX512BW-NEXT: retq
495 %a = icmp ne <2 x i64> %mask, zeroinitializer
496 %b = icmp slt <2 x i64> %x, <i64 2147483647, i64 2147483647>
497 %c = select <2 x i1> %b, <2 x i64> %x, <2 x i64> <i64 2147483647, i64 2147483647>
498 %d = icmp sgt <2 x i64> %c, <i64 -2147483648, i64 -2147483648>
499 %e = select <2 x i1> %d, <2 x i64> %c, <2 x i64> <i64 -2147483648, i64 -2147483648>
500 %f = trunc <2 x i64> %e to <2 x i32>
501 call void @llvm.masked.store.v2i32.p0v2i32(<2 x i32> %f, <2 x i32>* %p, i32 1, <2 x i1> %a)
505 define void @truncstore_v2i64_v2i16(<2 x i64> %x, <2 x i16>* %p, <2 x i64> %mask) {
506 ; AVX512F-LABEL: truncstore_v2i64_v2i16:
508 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
509 ; AVX512F-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
510 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
511 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm2 = [32767,32767]
512 ; AVX512F-NEXT: vpminsq %zmm2, %zmm0, %zmm0
513 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm2 = [18446744073709518848,18446744073709518848]
514 ; AVX512F-NEXT: vpmaxsq %zmm2, %zmm0, %zmm0
515 ; AVX512F-NEXT: kmovw %k0, %eax
516 ; AVX512F-NEXT: testb $1, %al
517 ; AVX512F-NEXT: je .LBB7_2
518 ; AVX512F-NEXT: # %bb.1: # %cond.store
519 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
520 ; AVX512F-NEXT: .LBB7_2: # %else
521 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
522 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
523 ; AVX512F-NEXT: kmovw %k0, %eax
524 ; AVX512F-NEXT: testb $1, %al
525 ; AVX512F-NEXT: je .LBB7_4
526 ; AVX512F-NEXT: # %bb.3: # %cond.store1
527 ; AVX512F-NEXT: vpextrw $4, %xmm0, 2(%rdi)
528 ; AVX512F-NEXT: .LBB7_4: # %else2
529 ; AVX512F-NEXT: vzeroupper
532 ; AVX512BW-LABEL: truncstore_v2i64_v2i16:
534 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
535 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
536 ; AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k0
537 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [32767,32767]
538 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
539 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [18446744073709518848,18446744073709518848]
540 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
541 ; AVX512BW-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
542 ; AVX512BW-NEXT: vpshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7]
543 ; AVX512BW-NEXT: kshiftld $30, %k0, %k0
544 ; AVX512BW-NEXT: kshiftrd $30, %k0, %k1
545 ; AVX512BW-NEXT: vmovdqu16 %zmm0, (%rdi) {%k1}
546 ; AVX512BW-NEXT: vzeroupper
547 ; AVX512BW-NEXT: retq
549 ; AVX512BWVL-LABEL: truncstore_v2i64_v2i16:
550 ; AVX512BWVL: # %bb.0:
551 ; AVX512BWVL-NEXT: vptestmq %xmm1, %xmm1, %k1
552 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip), %xmm0, %xmm0
553 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip), %xmm0, %xmm0
554 ; AVX512BWVL-NEXT: vpmovqw %xmm0, (%rdi) {%k1}
555 ; AVX512BWVL-NEXT: retq
556 %a = icmp ne <2 x i64> %mask, zeroinitializer
557 %b = icmp slt <2 x i64> %x, <i64 32767, i64 32767>
558 %c = select <2 x i1> %b, <2 x i64> %x, <2 x i64> <i64 32767, i64 32767>
559 %d = icmp sgt <2 x i64> %c, <i64 -32768, i64 -32768>
560 %e = select <2 x i1> %d, <2 x i64> %c, <2 x i64> <i64 -32768, i64 -32768>
561 %f = trunc <2 x i64> %e to <2 x i16>
562 call void @llvm.masked.store.v2i16.p0v2i16(<2 x i16> %f, <2 x i16>* %p, i32 1, <2 x i1> %a)
566 define void @truncstore_v2i64_v2i8(<2 x i64> %x, <2 x i8>* %p, <2 x i64> %mask) {
567 ; AVX512F-LABEL: truncstore_v2i64_v2i8:
569 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
570 ; AVX512F-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
571 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
572 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm2 = [127,127]
573 ; AVX512F-NEXT: vpminsq %zmm2, %zmm0, %zmm0
574 ; AVX512F-NEXT: vmovdqa {{.*#+}} xmm2 = [18446744073709551488,18446744073709551488]
575 ; AVX512F-NEXT: vpmaxsq %zmm2, %zmm0, %zmm0
576 ; AVX512F-NEXT: kmovw %k0, %eax
577 ; AVX512F-NEXT: testb $1, %al
578 ; AVX512F-NEXT: je .LBB8_2
579 ; AVX512F-NEXT: # %bb.1: # %cond.store
580 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
581 ; AVX512F-NEXT: .LBB8_2: # %else
582 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
583 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
584 ; AVX512F-NEXT: kmovw %k0, %eax
585 ; AVX512F-NEXT: testb $1, %al
586 ; AVX512F-NEXT: je .LBB8_4
587 ; AVX512F-NEXT: # %bb.3: # %cond.store1
588 ; AVX512F-NEXT: vpextrb $8, %xmm0, 1(%rdi)
589 ; AVX512F-NEXT: .LBB8_4: # %else2
590 ; AVX512F-NEXT: vzeroupper
593 ; AVX512BW-LABEL: truncstore_v2i64_v2i8:
595 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
596 ; AVX512BW-NEXT: # kill: def $xmm0 killed $xmm0 def $zmm0
597 ; AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k0
598 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [127,127]
599 ; AVX512BW-NEXT: vpminsq %zmm1, %zmm0, %zmm0
600 ; AVX512BW-NEXT: vmovdqa {{.*#+}} xmm1 = [18446744073709551488,18446744073709551488]
601 ; AVX512BW-NEXT: vpmaxsq %zmm1, %zmm0, %zmm0
602 ; AVX512BW-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,8,u,u,u,u,u,u,u,u,u,u,u,u,u,u]
603 ; AVX512BW-NEXT: kshiftlq $62, %k0, %k0
604 ; AVX512BW-NEXT: kshiftrq $62, %k0, %k1
605 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
606 ; AVX512BW-NEXT: vzeroupper
607 ; AVX512BW-NEXT: retq
609 ; AVX512BWVL-LABEL: truncstore_v2i64_v2i8:
610 ; AVX512BWVL: # %bb.0:
611 ; AVX512BWVL-NEXT: vptestmq %xmm1, %xmm1, %k1
612 ; AVX512BWVL-NEXT: vpminsq {{.*}}(%rip), %xmm0, %xmm0
613 ; AVX512BWVL-NEXT: vpmaxsq {{.*}}(%rip), %xmm0, %xmm0
614 ; AVX512BWVL-NEXT: vpmovqb %xmm0, (%rdi) {%k1}
615 ; AVX512BWVL-NEXT: retq
616 %a = icmp ne <2 x i64> %mask, zeroinitializer
617 %b = icmp slt <2 x i64> %x, <i64 127, i64 127>
618 %c = select <2 x i1> %b, <2 x i64> %x, <2 x i64> <i64 127, i64 127>
619 %d = icmp sgt <2 x i64> %c, <i64 -128, i64 -128>
620 %e = select <2 x i1> %d, <2 x i64> %c, <2 x i64> <i64 -128, i64 -128>
621 %f = trunc <2 x i64> %e to <2 x i8>
622 call void @llvm.masked.store.v2i8.p0v2i8(<2 x i8> %f, <2 x i8>* %p, i32 1, <2 x i1> %a)
626 define void @truncstore_v16i32_v16i16(<16 x i32> %x, <16 x i16>* %p, <16 x i32> %mask) {
627 ; AVX512F-LABEL: truncstore_v16i32_v16i16:
629 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
630 ; AVX512F-NEXT: vpmovsdw %zmm0, %ymm0
631 ; AVX512F-NEXT: kmovw %k0, %eax
632 ; AVX512F-NEXT: testb $1, %al
633 ; AVX512F-NEXT: je .LBB9_2
634 ; AVX512F-NEXT: # %bb.1: # %cond.store
635 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
636 ; AVX512F-NEXT: .LBB9_2: # %else
637 ; AVX512F-NEXT: kshiftrw $1, %k0, %k1
638 ; AVX512F-NEXT: kmovw %k1, %eax
639 ; AVX512F-NEXT: testb $1, %al
640 ; AVX512F-NEXT: je .LBB9_4
641 ; AVX512F-NEXT: # %bb.3: # %cond.store1
642 ; AVX512F-NEXT: vpextrw $1, %xmm0, 2(%rdi)
643 ; AVX512F-NEXT: .LBB9_4: # %else2
644 ; AVX512F-NEXT: kshiftrw $2, %k0, %k1
645 ; AVX512F-NEXT: kmovw %k1, %eax
646 ; AVX512F-NEXT: testb $1, %al
647 ; AVX512F-NEXT: je .LBB9_6
648 ; AVX512F-NEXT: # %bb.5: # %cond.store3
649 ; AVX512F-NEXT: vpextrw $2, %xmm0, 4(%rdi)
650 ; AVX512F-NEXT: .LBB9_6: # %else4
651 ; AVX512F-NEXT: kshiftrw $3, %k0, %k1
652 ; AVX512F-NEXT: kmovw %k1, %eax
653 ; AVX512F-NEXT: testb $1, %al
654 ; AVX512F-NEXT: je .LBB9_8
655 ; AVX512F-NEXT: # %bb.7: # %cond.store5
656 ; AVX512F-NEXT: vpextrw $3, %xmm0, 6(%rdi)
657 ; AVX512F-NEXT: .LBB9_8: # %else6
658 ; AVX512F-NEXT: kshiftrw $4, %k0, %k1
659 ; AVX512F-NEXT: kmovw %k1, %eax
660 ; AVX512F-NEXT: testb $1, %al
661 ; AVX512F-NEXT: je .LBB9_10
662 ; AVX512F-NEXT: # %bb.9: # %cond.store7
663 ; AVX512F-NEXT: vpextrw $4, %xmm0, 8(%rdi)
664 ; AVX512F-NEXT: .LBB9_10: # %else8
665 ; AVX512F-NEXT: kshiftrw $5, %k0, %k1
666 ; AVX512F-NEXT: kmovw %k1, %eax
667 ; AVX512F-NEXT: testb $1, %al
668 ; AVX512F-NEXT: je .LBB9_12
669 ; AVX512F-NEXT: # %bb.11: # %cond.store9
670 ; AVX512F-NEXT: vpextrw $5, %xmm0, 10(%rdi)
671 ; AVX512F-NEXT: .LBB9_12: # %else10
672 ; AVX512F-NEXT: kshiftrw $6, %k0, %k1
673 ; AVX512F-NEXT: kmovw %k1, %eax
674 ; AVX512F-NEXT: testb $1, %al
675 ; AVX512F-NEXT: je .LBB9_14
676 ; AVX512F-NEXT: # %bb.13: # %cond.store11
677 ; AVX512F-NEXT: vpextrw $6, %xmm0, 12(%rdi)
678 ; AVX512F-NEXT: .LBB9_14: # %else12
679 ; AVX512F-NEXT: kshiftrw $7, %k0, %k1
680 ; AVX512F-NEXT: kmovw %k1, %eax
681 ; AVX512F-NEXT: testb $1, %al
682 ; AVX512F-NEXT: je .LBB9_16
683 ; AVX512F-NEXT: # %bb.15: # %cond.store13
684 ; AVX512F-NEXT: vpextrw $7, %xmm0, 14(%rdi)
685 ; AVX512F-NEXT: .LBB9_16: # %else14
686 ; AVX512F-NEXT: kshiftrw $8, %k0, %k1
687 ; AVX512F-NEXT: kmovw %k1, %eax
688 ; AVX512F-NEXT: testb $1, %al
689 ; AVX512F-NEXT: je .LBB9_18
690 ; AVX512F-NEXT: # %bb.17: # %cond.store15
691 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
692 ; AVX512F-NEXT: vpextrw $0, %xmm1, 16(%rdi)
693 ; AVX512F-NEXT: .LBB9_18: # %else16
694 ; AVX512F-NEXT: kshiftrw $9, %k0, %k1
695 ; AVX512F-NEXT: kmovw %k1, %eax
696 ; AVX512F-NEXT: testb $1, %al
697 ; AVX512F-NEXT: je .LBB9_20
698 ; AVX512F-NEXT: # %bb.19: # %cond.store17
699 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
700 ; AVX512F-NEXT: vpextrw $1, %xmm1, 18(%rdi)
701 ; AVX512F-NEXT: .LBB9_20: # %else18
702 ; AVX512F-NEXT: kshiftrw $10, %k0, %k1
703 ; AVX512F-NEXT: kmovw %k1, %eax
704 ; AVX512F-NEXT: testb $1, %al
705 ; AVX512F-NEXT: je .LBB9_22
706 ; AVX512F-NEXT: # %bb.21: # %cond.store19
707 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
708 ; AVX512F-NEXT: vpextrw $2, %xmm1, 20(%rdi)
709 ; AVX512F-NEXT: .LBB9_22: # %else20
710 ; AVX512F-NEXT: kshiftrw $11, %k0, %k1
711 ; AVX512F-NEXT: kmovw %k1, %eax
712 ; AVX512F-NEXT: testb $1, %al
713 ; AVX512F-NEXT: je .LBB9_24
714 ; AVX512F-NEXT: # %bb.23: # %cond.store21
715 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
716 ; AVX512F-NEXT: vpextrw $3, %xmm1, 22(%rdi)
717 ; AVX512F-NEXT: .LBB9_24: # %else22
718 ; AVX512F-NEXT: kshiftrw $12, %k0, %k1
719 ; AVX512F-NEXT: kmovw %k1, %eax
720 ; AVX512F-NEXT: testb $1, %al
721 ; AVX512F-NEXT: je .LBB9_26
722 ; AVX512F-NEXT: # %bb.25: # %cond.store23
723 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
724 ; AVX512F-NEXT: vpextrw $4, %xmm1, 24(%rdi)
725 ; AVX512F-NEXT: .LBB9_26: # %else24
726 ; AVX512F-NEXT: kshiftrw $13, %k0, %k1
727 ; AVX512F-NEXT: kmovw %k1, %eax
728 ; AVX512F-NEXT: testb $1, %al
729 ; AVX512F-NEXT: je .LBB9_28
730 ; AVX512F-NEXT: # %bb.27: # %cond.store25
731 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
732 ; AVX512F-NEXT: vpextrw $5, %xmm1, 26(%rdi)
733 ; AVX512F-NEXT: .LBB9_28: # %else26
734 ; AVX512F-NEXT: kshiftrw $14, %k0, %k1
735 ; AVX512F-NEXT: kmovw %k1, %eax
736 ; AVX512F-NEXT: testb $1, %al
737 ; AVX512F-NEXT: je .LBB9_30
738 ; AVX512F-NEXT: # %bb.29: # %cond.store27
739 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
740 ; AVX512F-NEXT: vpextrw $6, %xmm1, 28(%rdi)
741 ; AVX512F-NEXT: .LBB9_30: # %else28
742 ; AVX512F-NEXT: kshiftrw $15, %k0, %k0
743 ; AVX512F-NEXT: kmovw %k0, %eax
744 ; AVX512F-NEXT: testb $1, %al
745 ; AVX512F-NEXT: je .LBB9_32
746 ; AVX512F-NEXT: # %bb.31: # %cond.store29
747 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm0
748 ; AVX512F-NEXT: vpextrw $7, %xmm0, 30(%rdi)
749 ; AVX512F-NEXT: .LBB9_32: # %else30
750 ; AVX512F-NEXT: vzeroupper
753 ; AVX512BW-LABEL: truncstore_v16i32_v16i16:
755 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k1
756 ; AVX512BW-NEXT: vpminsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
757 ; AVX512BW-NEXT: vpmaxsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
758 ; AVX512BW-NEXT: vpmovdw %zmm0, (%rdi) {%k1}
759 ; AVX512BW-NEXT: vzeroupper
760 ; AVX512BW-NEXT: retq
762 ; AVX512BWVL-LABEL: truncstore_v16i32_v16i16:
763 ; AVX512BWVL: # %bb.0:
764 ; AVX512BWVL-NEXT: vptestmd %zmm1, %zmm1, %k1
765 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
766 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
767 ; AVX512BWVL-NEXT: vpmovdw %zmm0, (%rdi) {%k1}
768 ; AVX512BWVL-NEXT: vzeroupper
769 ; AVX512BWVL-NEXT: retq
770 %a = icmp ne <16 x i32> %mask, zeroinitializer
771 %b = icmp slt <16 x i32> %x, <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>
772 %c = select <16 x i1> %b, <16 x i32> %x, <16 x i32> <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>
773 %d = icmp sgt <16 x i32> %c, <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>
774 %e = select <16 x i1> %d, <16 x i32> %c, <16 x i32> <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>
775 %f = trunc <16 x i32> %e to <16 x i16>
776 call void @llvm.masked.store.v16i16.p0v16i16(<16 x i16> %f, <16 x i16>* %p, i32 1, <16 x i1> %a)
780 define void @truncstore_v16i32_v16i8(<16 x i32> %x, <16 x i8>* %p, <16 x i32> %mask) {
781 ; AVX512F-LABEL: truncstore_v16i32_v16i8:
783 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
784 ; AVX512F-NEXT: vpmovsdb %zmm0, %xmm0
785 ; AVX512F-NEXT: kmovw %k0, %eax
786 ; AVX512F-NEXT: testb $1, %al
787 ; AVX512F-NEXT: je .LBB10_2
788 ; AVX512F-NEXT: # %bb.1: # %cond.store
789 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
790 ; AVX512F-NEXT: .LBB10_2: # %else
791 ; AVX512F-NEXT: kshiftrw $1, %k0, %k1
792 ; AVX512F-NEXT: kmovw %k1, %eax
793 ; AVX512F-NEXT: testb $1, %al
794 ; AVX512F-NEXT: je .LBB10_4
795 ; AVX512F-NEXT: # %bb.3: # %cond.store1
796 ; AVX512F-NEXT: vpextrb $1, %xmm0, 1(%rdi)
797 ; AVX512F-NEXT: .LBB10_4: # %else2
798 ; AVX512F-NEXT: kshiftrw $2, %k0, %k1
799 ; AVX512F-NEXT: kmovw %k1, %eax
800 ; AVX512F-NEXT: testb $1, %al
801 ; AVX512F-NEXT: je .LBB10_6
802 ; AVX512F-NEXT: # %bb.5: # %cond.store3
803 ; AVX512F-NEXT: vpextrb $2, %xmm0, 2(%rdi)
804 ; AVX512F-NEXT: .LBB10_6: # %else4
805 ; AVX512F-NEXT: kshiftrw $3, %k0, %k1
806 ; AVX512F-NEXT: kmovw %k1, %eax
807 ; AVX512F-NEXT: testb $1, %al
808 ; AVX512F-NEXT: je .LBB10_8
809 ; AVX512F-NEXT: # %bb.7: # %cond.store5
810 ; AVX512F-NEXT: vpextrb $3, %xmm0, 3(%rdi)
811 ; AVX512F-NEXT: .LBB10_8: # %else6
812 ; AVX512F-NEXT: kshiftrw $4, %k0, %k1
813 ; AVX512F-NEXT: kmovw %k1, %eax
814 ; AVX512F-NEXT: testb $1, %al
815 ; AVX512F-NEXT: je .LBB10_10
816 ; AVX512F-NEXT: # %bb.9: # %cond.store7
817 ; AVX512F-NEXT: vpextrb $4, %xmm0, 4(%rdi)
818 ; AVX512F-NEXT: .LBB10_10: # %else8
819 ; AVX512F-NEXT: kshiftrw $5, %k0, %k1
820 ; AVX512F-NEXT: kmovw %k1, %eax
821 ; AVX512F-NEXT: testb $1, %al
822 ; AVX512F-NEXT: je .LBB10_12
823 ; AVX512F-NEXT: # %bb.11: # %cond.store9
824 ; AVX512F-NEXT: vpextrb $5, %xmm0, 5(%rdi)
825 ; AVX512F-NEXT: .LBB10_12: # %else10
826 ; AVX512F-NEXT: kshiftrw $6, %k0, %k1
827 ; AVX512F-NEXT: kmovw %k1, %eax
828 ; AVX512F-NEXT: testb $1, %al
829 ; AVX512F-NEXT: je .LBB10_14
830 ; AVX512F-NEXT: # %bb.13: # %cond.store11
831 ; AVX512F-NEXT: vpextrb $6, %xmm0, 6(%rdi)
832 ; AVX512F-NEXT: .LBB10_14: # %else12
833 ; AVX512F-NEXT: kshiftrw $7, %k0, %k1
834 ; AVX512F-NEXT: kmovw %k1, %eax
835 ; AVX512F-NEXT: testb $1, %al
836 ; AVX512F-NEXT: je .LBB10_16
837 ; AVX512F-NEXT: # %bb.15: # %cond.store13
838 ; AVX512F-NEXT: vpextrb $7, %xmm0, 7(%rdi)
839 ; AVX512F-NEXT: .LBB10_16: # %else14
840 ; AVX512F-NEXT: kshiftrw $8, %k0, %k1
841 ; AVX512F-NEXT: kmovw %k1, %eax
842 ; AVX512F-NEXT: testb $1, %al
843 ; AVX512F-NEXT: je .LBB10_18
844 ; AVX512F-NEXT: # %bb.17: # %cond.store15
845 ; AVX512F-NEXT: vpextrb $8, %xmm0, 8(%rdi)
846 ; AVX512F-NEXT: .LBB10_18: # %else16
847 ; AVX512F-NEXT: kshiftrw $9, %k0, %k1
848 ; AVX512F-NEXT: kmovw %k1, %eax
849 ; AVX512F-NEXT: testb $1, %al
850 ; AVX512F-NEXT: je .LBB10_20
851 ; AVX512F-NEXT: # %bb.19: # %cond.store17
852 ; AVX512F-NEXT: vpextrb $9, %xmm0, 9(%rdi)
853 ; AVX512F-NEXT: .LBB10_20: # %else18
854 ; AVX512F-NEXT: kshiftrw $10, %k0, %k1
855 ; AVX512F-NEXT: kmovw %k1, %eax
856 ; AVX512F-NEXT: testb $1, %al
857 ; AVX512F-NEXT: je .LBB10_22
858 ; AVX512F-NEXT: # %bb.21: # %cond.store19
859 ; AVX512F-NEXT: vpextrb $10, %xmm0, 10(%rdi)
860 ; AVX512F-NEXT: .LBB10_22: # %else20
861 ; AVX512F-NEXT: kshiftrw $11, %k0, %k1
862 ; AVX512F-NEXT: kmovw %k1, %eax
863 ; AVX512F-NEXT: testb $1, %al
864 ; AVX512F-NEXT: je .LBB10_24
865 ; AVX512F-NEXT: # %bb.23: # %cond.store21
866 ; AVX512F-NEXT: vpextrb $11, %xmm0, 11(%rdi)
867 ; AVX512F-NEXT: .LBB10_24: # %else22
868 ; AVX512F-NEXT: kshiftrw $12, %k0, %k1
869 ; AVX512F-NEXT: kmovw %k1, %eax
870 ; AVX512F-NEXT: testb $1, %al
871 ; AVX512F-NEXT: je .LBB10_26
872 ; AVX512F-NEXT: # %bb.25: # %cond.store23
873 ; AVX512F-NEXT: vpextrb $12, %xmm0, 12(%rdi)
874 ; AVX512F-NEXT: .LBB10_26: # %else24
875 ; AVX512F-NEXT: kshiftrw $13, %k0, %k1
876 ; AVX512F-NEXT: kmovw %k1, %eax
877 ; AVX512F-NEXT: testb $1, %al
878 ; AVX512F-NEXT: je .LBB10_28
879 ; AVX512F-NEXT: # %bb.27: # %cond.store25
880 ; AVX512F-NEXT: vpextrb $13, %xmm0, 13(%rdi)
881 ; AVX512F-NEXT: .LBB10_28: # %else26
882 ; AVX512F-NEXT: kshiftrw $14, %k0, %k1
883 ; AVX512F-NEXT: kmovw %k1, %eax
884 ; AVX512F-NEXT: testb $1, %al
885 ; AVX512F-NEXT: je .LBB10_30
886 ; AVX512F-NEXT: # %bb.29: # %cond.store27
887 ; AVX512F-NEXT: vpextrb $14, %xmm0, 14(%rdi)
888 ; AVX512F-NEXT: .LBB10_30: # %else28
889 ; AVX512F-NEXT: kshiftrw $15, %k0, %k0
890 ; AVX512F-NEXT: kmovw %k0, %eax
891 ; AVX512F-NEXT: testb $1, %al
892 ; AVX512F-NEXT: je .LBB10_32
893 ; AVX512F-NEXT: # %bb.31: # %cond.store29
894 ; AVX512F-NEXT: vpextrb $15, %xmm0, 15(%rdi)
895 ; AVX512F-NEXT: .LBB10_32: # %else30
896 ; AVX512F-NEXT: vzeroupper
899 ; AVX512BW-LABEL: truncstore_v16i32_v16i8:
901 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k1
902 ; AVX512BW-NEXT: vpminsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
903 ; AVX512BW-NEXT: vpmaxsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
904 ; AVX512BW-NEXT: vpmovdb %zmm0, (%rdi) {%k1}
905 ; AVX512BW-NEXT: vzeroupper
906 ; AVX512BW-NEXT: retq
908 ; AVX512BWVL-LABEL: truncstore_v16i32_v16i8:
909 ; AVX512BWVL: # %bb.0:
910 ; AVX512BWVL-NEXT: vptestmd %zmm1, %zmm1, %k1
911 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
912 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to16}, %zmm0, %zmm0
913 ; AVX512BWVL-NEXT: vpmovdb %zmm0, (%rdi) {%k1}
914 ; AVX512BWVL-NEXT: vzeroupper
915 ; AVX512BWVL-NEXT: retq
916 %a = icmp ne <16 x i32> %mask, zeroinitializer
917 %b = icmp slt <16 x i32> %x, <i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127>
918 %c = select <16 x i1> %b, <16 x i32> %x, <16 x i32> <i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127>
919 %d = icmp sgt <16 x i32> %c, <i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128>
920 %e = select <16 x i1> %d, <16 x i32> %c, <16 x i32> <i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128>
921 %f = trunc <16 x i32> %e to <16 x i8>
922 call void @llvm.masked.store.v16i8.p0v16i8(<16 x i8> %f, <16 x i8>* %p, i32 1, <16 x i1> %a)
926 define void @truncstore_v8i32_v8i16(<8 x i32> %x, <8 x i16>* %p, <8 x i32> %mask) {
927 ; AVX512F-LABEL: truncstore_v8i32_v8i16:
929 ; AVX512F-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
930 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
931 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} ymm2 = [32767,32767,32767,32767,32767,32767,32767,32767]
932 ; AVX512F-NEXT: vpminsd %ymm2, %ymm0, %ymm0
933 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} ymm2 = [4294934528,4294934528,4294934528,4294934528,4294934528,4294934528,4294934528,4294934528]
934 ; AVX512F-NEXT: vpmaxsd %ymm2, %ymm0, %ymm0
935 ; AVX512F-NEXT: vpmovdw %zmm0, %ymm0
936 ; AVX512F-NEXT: kmovw %k0, %eax
937 ; AVX512F-NEXT: testb $1, %al
938 ; AVX512F-NEXT: je .LBB11_2
939 ; AVX512F-NEXT: # %bb.1: # %cond.store
940 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
941 ; AVX512F-NEXT: .LBB11_2: # %else
942 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
943 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
944 ; AVX512F-NEXT: kmovw %k0, %eax
945 ; AVX512F-NEXT: testb $1, %al
946 ; AVX512F-NEXT: je .LBB11_4
947 ; AVX512F-NEXT: # %bb.3: # %cond.store1
948 ; AVX512F-NEXT: vpextrw $1, %xmm0, 2(%rdi)
949 ; AVX512F-NEXT: .LBB11_4: # %else2
950 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
951 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
952 ; AVX512F-NEXT: kmovw %k0, %eax
953 ; AVX512F-NEXT: testb $1, %al
954 ; AVX512F-NEXT: je .LBB11_6
955 ; AVX512F-NEXT: # %bb.5: # %cond.store3
956 ; AVX512F-NEXT: vpextrw $2, %xmm0, 4(%rdi)
957 ; AVX512F-NEXT: .LBB11_6: # %else4
958 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
959 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
960 ; AVX512F-NEXT: kmovw %k0, %eax
961 ; AVX512F-NEXT: testb $1, %al
962 ; AVX512F-NEXT: je .LBB11_8
963 ; AVX512F-NEXT: # %bb.7: # %cond.store5
964 ; AVX512F-NEXT: vpextrw $3, %xmm0, 6(%rdi)
965 ; AVX512F-NEXT: .LBB11_8: # %else6
966 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
967 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
968 ; AVX512F-NEXT: kmovw %k0, %eax
969 ; AVX512F-NEXT: testb $1, %al
970 ; AVX512F-NEXT: je .LBB11_10
971 ; AVX512F-NEXT: # %bb.9: # %cond.store7
972 ; AVX512F-NEXT: vpextrw $4, %xmm0, 8(%rdi)
973 ; AVX512F-NEXT: .LBB11_10: # %else8
974 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
975 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
976 ; AVX512F-NEXT: kmovw %k0, %eax
977 ; AVX512F-NEXT: testb $1, %al
978 ; AVX512F-NEXT: je .LBB11_12
979 ; AVX512F-NEXT: # %bb.11: # %cond.store9
980 ; AVX512F-NEXT: vpextrw $5, %xmm0, 10(%rdi)
981 ; AVX512F-NEXT: .LBB11_12: # %else10
982 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
983 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
984 ; AVX512F-NEXT: kmovw %k0, %eax
985 ; AVX512F-NEXT: testb $1, %al
986 ; AVX512F-NEXT: je .LBB11_14
987 ; AVX512F-NEXT: # %bb.13: # %cond.store11
988 ; AVX512F-NEXT: vpextrw $6, %xmm0, 12(%rdi)
989 ; AVX512F-NEXT: .LBB11_14: # %else12
990 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
991 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
992 ; AVX512F-NEXT: kmovw %k0, %eax
993 ; AVX512F-NEXT: testb $1, %al
994 ; AVX512F-NEXT: je .LBB11_16
995 ; AVX512F-NEXT: # %bb.15: # %cond.store13
996 ; AVX512F-NEXT: vpextrw $7, %xmm0, 14(%rdi)
997 ; AVX512F-NEXT: .LBB11_16: # %else14
998 ; AVX512F-NEXT: vzeroupper
1001 ; AVX512BW-LABEL: truncstore_v8i32_v8i16:
1002 ; AVX512BW: # %bb.0:
1003 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
1004 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
1005 ; AVX512BW-NEXT: kshiftld $24, %k0, %k0
1006 ; AVX512BW-NEXT: kshiftrd $24, %k0, %k1
1007 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} ymm1 = [32767,32767,32767,32767,32767,32767,32767,32767]
1008 ; AVX512BW-NEXT: vpminsd %ymm1, %ymm0, %ymm0
1009 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} ymm1 = [4294934528,4294934528,4294934528,4294934528,4294934528,4294934528,4294934528,4294934528]
1010 ; AVX512BW-NEXT: vpmaxsd %ymm1, %ymm0, %ymm0
1011 ; AVX512BW-NEXT: vpmovdw %zmm0, %ymm0
1012 ; AVX512BW-NEXT: vmovdqu16 %zmm0, (%rdi) {%k1}
1013 ; AVX512BW-NEXT: vzeroupper
1014 ; AVX512BW-NEXT: retq
1016 ; AVX512BWVL-LABEL: truncstore_v8i32_v8i16:
1017 ; AVX512BWVL: # %bb.0:
1018 ; AVX512BWVL-NEXT: vptestmd %ymm1, %ymm1, %k1
1019 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
1020 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
1021 ; AVX512BWVL-NEXT: vpmovdw %ymm0, (%rdi) {%k1}
1022 ; AVX512BWVL-NEXT: vzeroupper
1023 ; AVX512BWVL-NEXT: retq
1024 %a = icmp ne <8 x i32> %mask, zeroinitializer
1025 %b = icmp slt <8 x i32> %x, <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>
1026 %c = select <8 x i1> %b, <8 x i32> %x, <8 x i32> <i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767, i32 32767>
1027 %d = icmp sgt <8 x i32> %c, <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>
1028 %e = select <8 x i1> %d, <8 x i32> %c, <8 x i32> <i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768, i32 -32768>
1029 %f = trunc <8 x i32> %e to <8 x i16>
1030 call void @llvm.masked.store.v8i16.p0v8i16(<8 x i16> %f, <8 x i16>* %p, i32 1, <8 x i1> %a)
1034 define void @truncstore_v8i32_v8i8(<8 x i32> %x, <8 x i8>* %p, <8 x i32> %mask) {
1035 ; AVX512F-LABEL: truncstore_v8i32_v8i8:
1037 ; AVX512F-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
1038 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1039 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} ymm2 = [127,127,127,127,127,127,127,127]
1040 ; AVX512F-NEXT: vpminsd %ymm2, %ymm0, %ymm0
1041 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} ymm2 = [4294967168,4294967168,4294967168,4294967168,4294967168,4294967168,4294967168,4294967168]
1042 ; AVX512F-NEXT: vpmaxsd %ymm2, %ymm0, %ymm0
1043 ; AVX512F-NEXT: vpmovdw %zmm0, %ymm0
1044 ; AVX512F-NEXT: kmovw %k0, %eax
1045 ; AVX512F-NEXT: testb $1, %al
1046 ; AVX512F-NEXT: je .LBB12_2
1047 ; AVX512F-NEXT: # %bb.1: # %cond.store
1048 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
1049 ; AVX512F-NEXT: .LBB12_2: # %else
1050 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1051 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1052 ; AVX512F-NEXT: kmovw %k0, %eax
1053 ; AVX512F-NEXT: testb $1, %al
1054 ; AVX512F-NEXT: je .LBB12_4
1055 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1056 ; AVX512F-NEXT: vpextrb $2, %xmm0, 1(%rdi)
1057 ; AVX512F-NEXT: .LBB12_4: # %else2
1058 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1059 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1060 ; AVX512F-NEXT: kmovw %k0, %eax
1061 ; AVX512F-NEXT: testb $1, %al
1062 ; AVX512F-NEXT: je .LBB12_6
1063 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1064 ; AVX512F-NEXT: vpextrb $4, %xmm0, 2(%rdi)
1065 ; AVX512F-NEXT: .LBB12_6: # %else4
1066 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1067 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1068 ; AVX512F-NEXT: kmovw %k0, %eax
1069 ; AVX512F-NEXT: testb $1, %al
1070 ; AVX512F-NEXT: je .LBB12_8
1071 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1072 ; AVX512F-NEXT: vpextrb $6, %xmm0, 3(%rdi)
1073 ; AVX512F-NEXT: .LBB12_8: # %else6
1074 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1075 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
1076 ; AVX512F-NEXT: kmovw %k0, %eax
1077 ; AVX512F-NEXT: testb $1, %al
1078 ; AVX512F-NEXT: je .LBB12_10
1079 ; AVX512F-NEXT: # %bb.9: # %cond.store7
1080 ; AVX512F-NEXT: vpextrb $8, %xmm0, 4(%rdi)
1081 ; AVX512F-NEXT: .LBB12_10: # %else8
1082 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1083 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
1084 ; AVX512F-NEXT: kmovw %k0, %eax
1085 ; AVX512F-NEXT: testb $1, %al
1086 ; AVX512F-NEXT: je .LBB12_12
1087 ; AVX512F-NEXT: # %bb.11: # %cond.store9
1088 ; AVX512F-NEXT: vpextrb $10, %xmm0, 5(%rdi)
1089 ; AVX512F-NEXT: .LBB12_12: # %else10
1090 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1091 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
1092 ; AVX512F-NEXT: kmovw %k0, %eax
1093 ; AVX512F-NEXT: testb $1, %al
1094 ; AVX512F-NEXT: je .LBB12_14
1095 ; AVX512F-NEXT: # %bb.13: # %cond.store11
1096 ; AVX512F-NEXT: vpextrb $12, %xmm0, 6(%rdi)
1097 ; AVX512F-NEXT: .LBB12_14: # %else12
1098 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1099 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
1100 ; AVX512F-NEXT: kmovw %k0, %eax
1101 ; AVX512F-NEXT: testb $1, %al
1102 ; AVX512F-NEXT: je .LBB12_16
1103 ; AVX512F-NEXT: # %bb.15: # %cond.store13
1104 ; AVX512F-NEXT: vpextrb $14, %xmm0, 7(%rdi)
1105 ; AVX512F-NEXT: .LBB12_16: # %else14
1106 ; AVX512F-NEXT: vzeroupper
1107 ; AVX512F-NEXT: retq
1109 ; AVX512BW-LABEL: truncstore_v8i32_v8i8:
1110 ; AVX512BW: # %bb.0:
1111 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
1112 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
1113 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} ymm1 = [127,127,127,127,127,127,127,127]
1114 ; AVX512BW-NEXT: vpminsd %ymm1, %ymm0, %ymm0
1115 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} ymm1 = [4294967168,4294967168,4294967168,4294967168,4294967168,4294967168,4294967168,4294967168]
1116 ; AVX512BW-NEXT: vpmaxsd %ymm1, %ymm0, %ymm0
1117 ; AVX512BW-NEXT: vpmovdw %zmm0, %ymm0
1118 ; AVX512BW-NEXT: vpacksswb %xmm0, %xmm0, %xmm0
1119 ; AVX512BW-NEXT: kshiftlq $56, %k0, %k0
1120 ; AVX512BW-NEXT: kshiftrq $56, %k0, %k1
1121 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
1122 ; AVX512BW-NEXT: vzeroupper
1123 ; AVX512BW-NEXT: retq
1125 ; AVX512BWVL-LABEL: truncstore_v8i32_v8i8:
1126 ; AVX512BWVL: # %bb.0:
1127 ; AVX512BWVL-NEXT: vptestmd %ymm1, %ymm1, %k1
1128 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
1129 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to8}, %ymm0, %ymm0
1130 ; AVX512BWVL-NEXT: vpmovdb %ymm0, (%rdi) {%k1}
1131 ; AVX512BWVL-NEXT: vzeroupper
1132 ; AVX512BWVL-NEXT: retq
1133 %a = icmp ne <8 x i32> %mask, zeroinitializer
1134 %b = icmp slt <8 x i32> %x, <i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127>
1135 %c = select <8 x i1> %b, <8 x i32> %x, <8 x i32> <i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127, i32 127>
1136 %d = icmp sgt <8 x i32> %c, <i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128>
1137 %e = select <8 x i1> %d, <8 x i32> %c, <8 x i32> <i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128, i32 -128>
1138 %f = trunc <8 x i32> %e to <8 x i8>
1139 call void @llvm.masked.store.v8i8.p0v8i8(<8 x i8> %f, <8 x i8>* %p, i32 1, <8 x i1> %a)
1143 define void @truncstore_v4i32_v4i16(<4 x i32> %x, <4 x i16>* %p, <4 x i32> %mask) {
1144 ; AVX512F-LABEL: truncstore_v4i32_v4i16:
1146 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
1147 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1148 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} xmm2 = [32767,32767,32767,32767]
1149 ; AVX512F-NEXT: vpminsd %xmm2, %xmm0, %xmm0
1150 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} xmm2 = [4294934528,4294934528,4294934528,4294934528]
1151 ; AVX512F-NEXT: vpmaxsd %xmm2, %xmm0, %xmm0
1152 ; AVX512F-NEXT: kmovw %k0, %eax
1153 ; AVX512F-NEXT: testb $1, %al
1154 ; AVX512F-NEXT: je .LBB13_2
1155 ; AVX512F-NEXT: # %bb.1: # %cond.store
1156 ; AVX512F-NEXT: vpextrw $0, %xmm0, (%rdi)
1157 ; AVX512F-NEXT: .LBB13_2: # %else
1158 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1159 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1160 ; AVX512F-NEXT: kmovw %k0, %eax
1161 ; AVX512F-NEXT: testb $1, %al
1162 ; AVX512F-NEXT: je .LBB13_4
1163 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1164 ; AVX512F-NEXT: vpextrw $2, %xmm0, 2(%rdi)
1165 ; AVX512F-NEXT: .LBB13_4: # %else2
1166 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1167 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1168 ; AVX512F-NEXT: kmovw %k0, %eax
1169 ; AVX512F-NEXT: testb $1, %al
1170 ; AVX512F-NEXT: je .LBB13_6
1171 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1172 ; AVX512F-NEXT: vpextrw $4, %xmm0, 4(%rdi)
1173 ; AVX512F-NEXT: .LBB13_6: # %else4
1174 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1175 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1176 ; AVX512F-NEXT: kmovw %k0, %eax
1177 ; AVX512F-NEXT: testb $1, %al
1178 ; AVX512F-NEXT: je .LBB13_8
1179 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1180 ; AVX512F-NEXT: vpextrw $6, %xmm0, 6(%rdi)
1181 ; AVX512F-NEXT: .LBB13_8: # %else6
1182 ; AVX512F-NEXT: vzeroupper
1183 ; AVX512F-NEXT: retq
1185 ; AVX512BW-LABEL: truncstore_v4i32_v4i16:
1186 ; AVX512BW: # %bb.0:
1187 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
1188 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
1189 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} xmm1 = [32767,32767,32767,32767]
1190 ; AVX512BW-NEXT: vpminsd %xmm1, %xmm0, %xmm0
1191 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} xmm1 = [4294934528,4294934528,4294934528,4294934528]
1192 ; AVX512BW-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
1193 ; AVX512BW-NEXT: vpackssdw %xmm0, %xmm0, %xmm0
1194 ; AVX512BW-NEXT: kshiftld $28, %k0, %k0
1195 ; AVX512BW-NEXT: kshiftrd $28, %k0, %k1
1196 ; AVX512BW-NEXT: vmovdqu16 %zmm0, (%rdi) {%k1}
1197 ; AVX512BW-NEXT: vzeroupper
1198 ; AVX512BW-NEXT: retq
1200 ; AVX512BWVL-LABEL: truncstore_v4i32_v4i16:
1201 ; AVX512BWVL: # %bb.0:
1202 ; AVX512BWVL-NEXT: vptestmd %xmm1, %xmm1, %k1
1203 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to4}, %xmm0, %xmm0
1204 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to4}, %xmm0, %xmm0
1205 ; AVX512BWVL-NEXT: vpmovdw %xmm0, (%rdi) {%k1}
1206 ; AVX512BWVL-NEXT: retq
1207 %a = icmp ne <4 x i32> %mask, zeroinitializer
1208 %b = icmp slt <4 x i32> %x, <i32 32767, i32 32767, i32 32767, i32 32767>
1209 %c = select <4 x i1> %b, <4 x i32> %x, <4 x i32> <i32 32767, i32 32767, i32 32767, i32 32767>
1210 %d = icmp sgt <4 x i32> %c, <i32 -32768, i32 -32768, i32 -32768, i32 -32768>
1211 %e = select <4 x i1> %d, <4 x i32> %c, <4 x i32> <i32 -32768, i32 -32768, i32 -32768, i32 -32768>
1212 %f = trunc <4 x i32> %e to <4 x i16>
1213 call void @llvm.masked.store.v4i16.p0v4i16(<4 x i16> %f, <4 x i16>* %p, i32 1, <4 x i1> %a)
1217 define void @truncstore_v4i32_v4i8(<4 x i32> %x, <4 x i8>* %p, <4 x i32> %mask) {
1218 ; AVX512F-LABEL: truncstore_v4i32_v4i8:
1220 ; AVX512F-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
1221 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1222 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} xmm2 = [127,127,127,127]
1223 ; AVX512F-NEXT: vpminsd %xmm2, %xmm0, %xmm0
1224 ; AVX512F-NEXT: vpbroadcastd {{.*#+}} xmm2 = [4294967168,4294967168,4294967168,4294967168]
1225 ; AVX512F-NEXT: vpmaxsd %xmm2, %xmm0, %xmm0
1226 ; AVX512F-NEXT: kmovw %k0, %eax
1227 ; AVX512F-NEXT: testb $1, %al
1228 ; AVX512F-NEXT: je .LBB14_2
1229 ; AVX512F-NEXT: # %bb.1: # %cond.store
1230 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
1231 ; AVX512F-NEXT: .LBB14_2: # %else
1232 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1233 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1234 ; AVX512F-NEXT: kmovw %k0, %eax
1235 ; AVX512F-NEXT: testb $1, %al
1236 ; AVX512F-NEXT: je .LBB14_4
1237 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1238 ; AVX512F-NEXT: vpextrb $4, %xmm0, 1(%rdi)
1239 ; AVX512F-NEXT: .LBB14_4: # %else2
1240 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1241 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1242 ; AVX512F-NEXT: kmovw %k0, %eax
1243 ; AVX512F-NEXT: testb $1, %al
1244 ; AVX512F-NEXT: je .LBB14_6
1245 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1246 ; AVX512F-NEXT: vpextrb $8, %xmm0, 2(%rdi)
1247 ; AVX512F-NEXT: .LBB14_6: # %else4
1248 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1249 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1250 ; AVX512F-NEXT: kmovw %k0, %eax
1251 ; AVX512F-NEXT: testb $1, %al
1252 ; AVX512F-NEXT: je .LBB14_8
1253 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1254 ; AVX512F-NEXT: vpextrb $12, %xmm0, 3(%rdi)
1255 ; AVX512F-NEXT: .LBB14_8: # %else6
1256 ; AVX512F-NEXT: vzeroupper
1257 ; AVX512F-NEXT: retq
1259 ; AVX512BW-LABEL: truncstore_v4i32_v4i8:
1260 ; AVX512BW: # %bb.0:
1261 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
1262 ; AVX512BW-NEXT: vptestmd %zmm1, %zmm1, %k0
1263 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} xmm1 = [127,127,127,127]
1264 ; AVX512BW-NEXT: vpminsd %xmm1, %xmm0, %xmm0
1265 ; AVX512BW-NEXT: vpbroadcastd {{.*#+}} xmm1 = [4294967168,4294967168,4294967168,4294967168]
1266 ; AVX512BW-NEXT: vpmaxsd %xmm1, %xmm0, %xmm0
1267 ; AVX512BW-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u]
1268 ; AVX512BW-NEXT: kshiftlq $60, %k0, %k0
1269 ; AVX512BW-NEXT: kshiftrq $60, %k0, %k1
1270 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
1271 ; AVX512BW-NEXT: vzeroupper
1272 ; AVX512BW-NEXT: retq
1274 ; AVX512BWVL-LABEL: truncstore_v4i32_v4i8:
1275 ; AVX512BWVL: # %bb.0:
1276 ; AVX512BWVL-NEXT: vptestmd %xmm1, %xmm1, %k1
1277 ; AVX512BWVL-NEXT: vpminsd {{.*}}(%rip){1to4}, %xmm0, %xmm0
1278 ; AVX512BWVL-NEXT: vpmaxsd {{.*}}(%rip){1to4}, %xmm0, %xmm0
1279 ; AVX512BWVL-NEXT: vpmovdb %xmm0, (%rdi) {%k1}
1280 ; AVX512BWVL-NEXT: retq
1281 %a = icmp ne <4 x i32> %mask, zeroinitializer
1282 %b = icmp slt <4 x i32> %x, <i32 127, i32 127, i32 127, i32 127>
1283 %c = select <4 x i1> %b, <4 x i32> %x, <4 x i32> <i32 127, i32 127, i32 127, i32 127>
1284 %d = icmp sgt <4 x i32> %c, <i32 -128, i32 -128, i32 -128, i32 -128>
1285 %e = select <4 x i1> %d, <4 x i32> %c, <4 x i32> <i32 -128, i32 -128, i32 -128, i32 -128>
1286 %f = trunc <4 x i32> %e to <4 x i8>
1287 call void @llvm.masked.store.v4i8.p0v4i8(<4 x i8> %f, <4 x i8>* %p, i32 1, <4 x i1> %a)
1291 define void @truncstore_v32i16_v32i8(<32 x i16> %x, <32 x i8>* %p, <32 x i8> %mask) {
1292 ; AVX512F-LABEL: truncstore_v32i16_v32i8:
1294 ; AVX512F-NEXT: vpxor %xmm3, %xmm3, %xmm3
1295 ; AVX512F-NEXT: vpcmpeqb %ymm3, %ymm2, %ymm3
1296 ; AVX512F-NEXT: vmovdqa64 %zmm3, %zmm4
1297 ; AVX512F-NEXT: vpternlogq $15, %zmm3, %zmm3, %zmm4
1298 ; AVX512F-NEXT: vpmovsxbd %xmm4, %zmm4
1299 ; AVX512F-NEXT: vptestmd %zmm4, %zmm4, %k0
1300 ; AVX512F-NEXT: vmovdqa {{.*#+}} ymm4 = [127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127]
1301 ; AVX512F-NEXT: vpminsw %ymm4, %ymm0, %ymm0
1302 ; AVX512F-NEXT: vpminsw %ymm4, %ymm1, %ymm1
1303 ; AVX512F-NEXT: vmovdqa {{.*#+}} ymm4 = [65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408,65408]
1304 ; AVX512F-NEXT: vpmaxsw %ymm4, %ymm1, %ymm1
1305 ; AVX512F-NEXT: vpmaxsw %ymm4, %ymm0, %ymm0
1306 ; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero
1307 ; AVX512F-NEXT: vpmovdb %zmm0, %xmm0
1308 ; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm1 = ymm1[0],zero,ymm1[1],zero,ymm1[2],zero,ymm1[3],zero,ymm1[4],zero,ymm1[5],zero,ymm1[6],zero,ymm1[7],zero,ymm1[8],zero,ymm1[9],zero,ymm1[10],zero,ymm1[11],zero,ymm1[12],zero,ymm1[13],zero,ymm1[14],zero,ymm1[15],zero
1309 ; AVX512F-NEXT: vpmovdb %zmm1, %xmm1
1310 ; AVX512F-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0
1311 ; AVX512F-NEXT: kmovw %k0, %eax
1312 ; AVX512F-NEXT: testb $1, %al
1313 ; AVX512F-NEXT: je .LBB15_2
1314 ; AVX512F-NEXT: # %bb.1: # %cond.store
1315 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
1316 ; AVX512F-NEXT: .LBB15_2: # %else
1317 ; AVX512F-NEXT: vpternlogq $15, %zmm3, %zmm3, %zmm3
1318 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm1
1319 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1320 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1321 ; AVX512F-NEXT: kmovw %k0, %eax
1322 ; AVX512F-NEXT: testb $1, %al
1323 ; AVX512F-NEXT: je .LBB15_4
1324 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1325 ; AVX512F-NEXT: vpextrb $1, %xmm0, 1(%rdi)
1326 ; AVX512F-NEXT: .LBB15_4: # %else2
1327 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1328 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1329 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1330 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1331 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1332 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1333 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1334 ; AVX512F-NEXT: kmovw %k0, %eax
1335 ; AVX512F-NEXT: testb $1, %al
1336 ; AVX512F-NEXT: je .LBB15_6
1337 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1338 ; AVX512F-NEXT: vpextrb $2, %xmm0, 2(%rdi)
1339 ; AVX512F-NEXT: .LBB15_6: # %else4
1340 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1341 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1342 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1343 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1344 ; AVX512F-NEXT: kmovw %k0, %eax
1345 ; AVX512F-NEXT: testb $1, %al
1346 ; AVX512F-NEXT: je .LBB15_8
1347 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1348 ; AVX512F-NEXT: vpextrb $3, %xmm0, 3(%rdi)
1349 ; AVX512F-NEXT: .LBB15_8: # %else6
1350 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1351 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1352 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1353 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1354 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1355 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1356 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
1357 ; AVX512F-NEXT: kmovw %k0, %eax
1358 ; AVX512F-NEXT: testb $1, %al
1359 ; AVX512F-NEXT: je .LBB15_10
1360 ; AVX512F-NEXT: # %bb.9: # %cond.store7
1361 ; AVX512F-NEXT: vpextrb $4, %xmm0, 4(%rdi)
1362 ; AVX512F-NEXT: .LBB15_10: # %else8
1363 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1364 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1365 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1366 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
1367 ; AVX512F-NEXT: kmovw %k0, %eax
1368 ; AVX512F-NEXT: testb $1, %al
1369 ; AVX512F-NEXT: je .LBB15_12
1370 ; AVX512F-NEXT: # %bb.11: # %cond.store9
1371 ; AVX512F-NEXT: vpextrb $5, %xmm0, 5(%rdi)
1372 ; AVX512F-NEXT: .LBB15_12: # %else10
1373 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1374 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1375 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1376 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1377 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1378 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1379 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
1380 ; AVX512F-NEXT: kmovw %k0, %eax
1381 ; AVX512F-NEXT: testb $1, %al
1382 ; AVX512F-NEXT: je .LBB15_14
1383 ; AVX512F-NEXT: # %bb.13: # %cond.store11
1384 ; AVX512F-NEXT: vpextrb $6, %xmm0, 6(%rdi)
1385 ; AVX512F-NEXT: .LBB15_14: # %else12
1386 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1387 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1388 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1389 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
1390 ; AVX512F-NEXT: kmovw %k0, %eax
1391 ; AVX512F-NEXT: testb $1, %al
1392 ; AVX512F-NEXT: je .LBB15_16
1393 ; AVX512F-NEXT: # %bb.15: # %cond.store13
1394 ; AVX512F-NEXT: vpextrb $7, %xmm0, 7(%rdi)
1395 ; AVX512F-NEXT: .LBB15_16: # %else14
1396 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1397 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1398 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1399 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1400 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1401 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1402 ; AVX512F-NEXT: kshiftrw $8, %k0, %k0
1403 ; AVX512F-NEXT: kmovw %k0, %eax
1404 ; AVX512F-NEXT: testb $1, %al
1405 ; AVX512F-NEXT: je .LBB15_18
1406 ; AVX512F-NEXT: # %bb.17: # %cond.store15
1407 ; AVX512F-NEXT: vpextrb $8, %xmm0, 8(%rdi)
1408 ; AVX512F-NEXT: .LBB15_18: # %else16
1409 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1410 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1411 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1412 ; AVX512F-NEXT: kshiftrw $9, %k0, %k0
1413 ; AVX512F-NEXT: kmovw %k0, %eax
1414 ; AVX512F-NEXT: testb $1, %al
1415 ; AVX512F-NEXT: je .LBB15_20
1416 ; AVX512F-NEXT: # %bb.19: # %cond.store17
1417 ; AVX512F-NEXT: vpextrb $9, %xmm0, 9(%rdi)
1418 ; AVX512F-NEXT: .LBB15_20: # %else18
1419 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1420 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1421 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1422 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1423 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1424 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1425 ; AVX512F-NEXT: kshiftrw $10, %k0, %k0
1426 ; AVX512F-NEXT: kmovw %k0, %eax
1427 ; AVX512F-NEXT: testb $1, %al
1428 ; AVX512F-NEXT: je .LBB15_22
1429 ; AVX512F-NEXT: # %bb.21: # %cond.store19
1430 ; AVX512F-NEXT: vpextrb $10, %xmm0, 10(%rdi)
1431 ; AVX512F-NEXT: .LBB15_22: # %else20
1432 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1433 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1434 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1435 ; AVX512F-NEXT: kshiftrw $11, %k0, %k0
1436 ; AVX512F-NEXT: kmovw %k0, %eax
1437 ; AVX512F-NEXT: testb $1, %al
1438 ; AVX512F-NEXT: je .LBB15_24
1439 ; AVX512F-NEXT: # %bb.23: # %cond.store21
1440 ; AVX512F-NEXT: vpextrb $11, %xmm0, 11(%rdi)
1441 ; AVX512F-NEXT: .LBB15_24: # %else22
1442 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1443 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1444 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1445 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1446 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1447 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1448 ; AVX512F-NEXT: kshiftrw $12, %k0, %k0
1449 ; AVX512F-NEXT: kmovw %k0, %eax
1450 ; AVX512F-NEXT: testb $1, %al
1451 ; AVX512F-NEXT: je .LBB15_26
1452 ; AVX512F-NEXT: # %bb.25: # %cond.store23
1453 ; AVX512F-NEXT: vpextrb $12, %xmm0, 12(%rdi)
1454 ; AVX512F-NEXT: .LBB15_26: # %else24
1455 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1456 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1457 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1458 ; AVX512F-NEXT: kshiftrw $13, %k0, %k0
1459 ; AVX512F-NEXT: kmovw %k0, %eax
1460 ; AVX512F-NEXT: testb $1, %al
1461 ; AVX512F-NEXT: je .LBB15_28
1462 ; AVX512F-NEXT: # %bb.27: # %cond.store25
1463 ; AVX512F-NEXT: vpextrb $13, %xmm0, 13(%rdi)
1464 ; AVX512F-NEXT: .LBB15_28: # %else26
1465 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1466 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1467 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1468 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1469 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1470 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1471 ; AVX512F-NEXT: kshiftrw $14, %k0, %k0
1472 ; AVX512F-NEXT: kmovw %k0, %eax
1473 ; AVX512F-NEXT: testb $1, %al
1474 ; AVX512F-NEXT: je .LBB15_30
1475 ; AVX512F-NEXT: # %bb.29: # %cond.store27
1476 ; AVX512F-NEXT: vpextrb $14, %xmm0, 14(%rdi)
1477 ; AVX512F-NEXT: .LBB15_30: # %else28
1478 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1479 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1480 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1481 ; AVX512F-NEXT: kshiftrw $15, %k0, %k0
1482 ; AVX512F-NEXT: kmovw %k0, %eax
1483 ; AVX512F-NEXT: testb $1, %al
1484 ; AVX512F-NEXT: je .LBB15_32
1485 ; AVX512F-NEXT: # %bb.31: # %cond.store29
1486 ; AVX512F-NEXT: vpextrb $15, %xmm0, 15(%rdi)
1487 ; AVX512F-NEXT: .LBB15_32: # %else30
1488 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1489 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1490 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1491 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1492 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1493 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1494 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1495 ; AVX512F-NEXT: kmovw %k0, %eax
1496 ; AVX512F-NEXT: testb $1, %al
1497 ; AVX512F-NEXT: je .LBB15_34
1498 ; AVX512F-NEXT: # %bb.33: # %cond.store31
1499 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1500 ; AVX512F-NEXT: vpextrb $0, %xmm3, 16(%rdi)
1501 ; AVX512F-NEXT: .LBB15_34: # %else32
1502 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1503 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1504 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1505 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1506 ; AVX512F-NEXT: kmovw %k0, %eax
1507 ; AVX512F-NEXT: testb $1, %al
1508 ; AVX512F-NEXT: je .LBB15_36
1509 ; AVX512F-NEXT: # %bb.35: # %cond.store33
1510 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1511 ; AVX512F-NEXT: vpextrb $1, %xmm1, 17(%rdi)
1512 ; AVX512F-NEXT: .LBB15_36: # %else34
1513 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1514 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1515 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1516 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1517 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1518 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1519 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1520 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1521 ; AVX512F-NEXT: kmovw %k0, %eax
1522 ; AVX512F-NEXT: testb $1, %al
1523 ; AVX512F-NEXT: je .LBB15_38
1524 ; AVX512F-NEXT: # %bb.37: # %cond.store35
1525 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1526 ; AVX512F-NEXT: vpextrb $2, %xmm3, 18(%rdi)
1527 ; AVX512F-NEXT: .LBB15_38: # %else36
1528 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1529 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1530 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1531 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1532 ; AVX512F-NEXT: kmovw %k0, %eax
1533 ; AVX512F-NEXT: testb $1, %al
1534 ; AVX512F-NEXT: je .LBB15_40
1535 ; AVX512F-NEXT: # %bb.39: # %cond.store37
1536 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1537 ; AVX512F-NEXT: vpextrb $3, %xmm1, 19(%rdi)
1538 ; AVX512F-NEXT: .LBB15_40: # %else38
1539 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1540 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1541 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1542 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1543 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1544 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1545 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1546 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
1547 ; AVX512F-NEXT: kmovw %k0, %eax
1548 ; AVX512F-NEXT: testb $1, %al
1549 ; AVX512F-NEXT: je .LBB15_42
1550 ; AVX512F-NEXT: # %bb.41: # %cond.store39
1551 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1552 ; AVX512F-NEXT: vpextrb $4, %xmm3, 20(%rdi)
1553 ; AVX512F-NEXT: .LBB15_42: # %else40
1554 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1555 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1556 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1557 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
1558 ; AVX512F-NEXT: kmovw %k0, %eax
1559 ; AVX512F-NEXT: testb $1, %al
1560 ; AVX512F-NEXT: je .LBB15_44
1561 ; AVX512F-NEXT: # %bb.43: # %cond.store41
1562 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1563 ; AVX512F-NEXT: vpextrb $5, %xmm1, 21(%rdi)
1564 ; AVX512F-NEXT: .LBB15_44: # %else42
1565 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1566 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1567 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1568 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1569 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1570 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1571 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1572 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
1573 ; AVX512F-NEXT: kmovw %k0, %eax
1574 ; AVX512F-NEXT: testb $1, %al
1575 ; AVX512F-NEXT: je .LBB15_46
1576 ; AVX512F-NEXT: # %bb.45: # %cond.store43
1577 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1578 ; AVX512F-NEXT: vpextrb $6, %xmm3, 22(%rdi)
1579 ; AVX512F-NEXT: .LBB15_46: # %else44
1580 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1581 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1582 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1583 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
1584 ; AVX512F-NEXT: kmovw %k0, %eax
1585 ; AVX512F-NEXT: testb $1, %al
1586 ; AVX512F-NEXT: je .LBB15_48
1587 ; AVX512F-NEXT: # %bb.47: # %cond.store45
1588 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1589 ; AVX512F-NEXT: vpextrb $7, %xmm1, 23(%rdi)
1590 ; AVX512F-NEXT: .LBB15_48: # %else46
1591 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1592 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1593 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1594 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1595 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1596 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1597 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1598 ; AVX512F-NEXT: kshiftrw $8, %k0, %k0
1599 ; AVX512F-NEXT: kmovw %k0, %eax
1600 ; AVX512F-NEXT: testb $1, %al
1601 ; AVX512F-NEXT: je .LBB15_50
1602 ; AVX512F-NEXT: # %bb.49: # %cond.store47
1603 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1604 ; AVX512F-NEXT: vpextrb $8, %xmm3, 24(%rdi)
1605 ; AVX512F-NEXT: .LBB15_50: # %else48
1606 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1607 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1608 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1609 ; AVX512F-NEXT: kshiftrw $9, %k0, %k0
1610 ; AVX512F-NEXT: kmovw %k0, %eax
1611 ; AVX512F-NEXT: testb $1, %al
1612 ; AVX512F-NEXT: je .LBB15_52
1613 ; AVX512F-NEXT: # %bb.51: # %cond.store49
1614 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1615 ; AVX512F-NEXT: vpextrb $9, %xmm1, 25(%rdi)
1616 ; AVX512F-NEXT: .LBB15_52: # %else50
1617 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1618 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1619 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1620 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1621 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1622 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1623 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1624 ; AVX512F-NEXT: kshiftrw $10, %k0, %k0
1625 ; AVX512F-NEXT: kmovw %k0, %eax
1626 ; AVX512F-NEXT: testb $1, %al
1627 ; AVX512F-NEXT: je .LBB15_54
1628 ; AVX512F-NEXT: # %bb.53: # %cond.store51
1629 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1630 ; AVX512F-NEXT: vpextrb $10, %xmm3, 26(%rdi)
1631 ; AVX512F-NEXT: .LBB15_54: # %else52
1632 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1633 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1634 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1635 ; AVX512F-NEXT: kshiftrw $11, %k0, %k0
1636 ; AVX512F-NEXT: kmovw %k0, %eax
1637 ; AVX512F-NEXT: testb $1, %al
1638 ; AVX512F-NEXT: je .LBB15_56
1639 ; AVX512F-NEXT: # %bb.55: # %cond.store53
1640 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1641 ; AVX512F-NEXT: vpextrb $11, %xmm1, 27(%rdi)
1642 ; AVX512F-NEXT: .LBB15_56: # %else54
1643 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1644 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1645 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1646 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm3
1647 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm3
1648 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1649 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1650 ; AVX512F-NEXT: kshiftrw $12, %k0, %k0
1651 ; AVX512F-NEXT: kmovw %k0, %eax
1652 ; AVX512F-NEXT: testb $1, %al
1653 ; AVX512F-NEXT: je .LBB15_58
1654 ; AVX512F-NEXT: # %bb.57: # %cond.store55
1655 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm3
1656 ; AVX512F-NEXT: vpextrb $12, %xmm3, 28(%rdi)
1657 ; AVX512F-NEXT: .LBB15_58: # %else56
1658 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1659 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1660 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1661 ; AVX512F-NEXT: kshiftrw $13, %k0, %k0
1662 ; AVX512F-NEXT: kmovw %k0, %eax
1663 ; AVX512F-NEXT: testb $1, %al
1664 ; AVX512F-NEXT: je .LBB15_60
1665 ; AVX512F-NEXT: # %bb.59: # %cond.store57
1666 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
1667 ; AVX512F-NEXT: vpextrb $13, %xmm1, 29(%rdi)
1668 ; AVX512F-NEXT: .LBB15_60: # %else58
1669 ; AVX512F-NEXT: vpxor %xmm1, %xmm1, %xmm1
1670 ; AVX512F-NEXT: vpcmpeqb %ymm1, %ymm2, %ymm1
1671 ; AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
1672 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm2
1673 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm2
1674 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1675 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1676 ; AVX512F-NEXT: kshiftrw $14, %k0, %k0
1677 ; AVX512F-NEXT: kmovw %k0, %eax
1678 ; AVX512F-NEXT: testb $1, %al
1679 ; AVX512F-NEXT: je .LBB15_62
1680 ; AVX512F-NEXT: # %bb.61: # %cond.store59
1681 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm2
1682 ; AVX512F-NEXT: vpextrb $14, %xmm2, 30(%rdi)
1683 ; AVX512F-NEXT: .LBB15_62: # %else60
1684 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1685 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1686 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1687 ; AVX512F-NEXT: kshiftrw $15, %k0, %k0
1688 ; AVX512F-NEXT: kmovw %k0, %eax
1689 ; AVX512F-NEXT: testb $1, %al
1690 ; AVX512F-NEXT: je .LBB15_64
1691 ; AVX512F-NEXT: # %bb.63: # %cond.store61
1692 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm0
1693 ; AVX512F-NEXT: vpextrb $15, %xmm0, 31(%rdi)
1694 ; AVX512F-NEXT: .LBB15_64: # %else62
1695 ; AVX512F-NEXT: vzeroupper
1696 ; AVX512F-NEXT: retq
1698 ; AVX512BW-LABEL: truncstore_v32i16_v32i8:
1699 ; AVX512BW: # %bb.0:
1700 ; AVX512BW-NEXT: # kill: def $ymm1 killed $ymm1 def $zmm1
1701 ; AVX512BW-NEXT: vptestmb %zmm1, %zmm1, %k1
1702 ; AVX512BW-NEXT: vpminsw {{.*}}(%rip), %zmm0, %zmm0
1703 ; AVX512BW-NEXT: vpmaxsw {{.*}}(%rip), %zmm0, %zmm0
1704 ; AVX512BW-NEXT: vpmovwb %zmm0, (%rdi) {%k1}
1705 ; AVX512BW-NEXT: vzeroupper
1706 ; AVX512BW-NEXT: retq
1708 ; AVX512BWVL-LABEL: truncstore_v32i16_v32i8:
1709 ; AVX512BWVL: # %bb.0:
1710 ; AVX512BWVL-NEXT: vptestmb %ymm1, %ymm1, %k1
1711 ; AVX512BWVL-NEXT: vpminsw {{.*}}(%rip), %zmm0, %zmm0
1712 ; AVX512BWVL-NEXT: vpmaxsw {{.*}}(%rip), %zmm0, %zmm0
1713 ; AVX512BWVL-NEXT: vpmovwb %zmm0, (%rdi) {%k1}
1714 ; AVX512BWVL-NEXT: vzeroupper
1715 ; AVX512BWVL-NEXT: retq
1716 %a = icmp ne <32 x i8> %mask, zeroinitializer
1717 %b = icmp slt <32 x i16> %x, <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
1718 %c = select <32 x i1> %b, <32 x i16> %x, <32 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
1719 %d = icmp sgt <32 x i16> %c, <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
1720 %e = select <32 x i1> %d, <32 x i16> %c, <32 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
1721 %f = trunc <32 x i16> %e to <32 x i8>
1722 call void @llvm.masked.store.v32i8.p0v32i8(<32 x i8> %f, <32 x i8>* %p, i32 1, <32 x i1> %a)
1726 define void @truncstore_v16i16_v16i8(<16 x i16> %x, <16 x i8>* %p, <16 x i8> %mask) {
1727 ; AVX512F-LABEL: truncstore_v16i16_v16i8:
1729 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1730 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1731 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1732 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1733 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1734 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1735 ; AVX512F-NEXT: vpminsw {{.*}}(%rip), %ymm0, %ymm0
1736 ; AVX512F-NEXT: vpmaxsw {{.*}}(%rip), %ymm0, %ymm0
1737 ; AVX512F-NEXT: vpmovzxwd {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero,ymm0[8],zero,ymm0[9],zero,ymm0[10],zero,ymm0[11],zero,ymm0[12],zero,ymm0[13],zero,ymm0[14],zero,ymm0[15],zero
1738 ; AVX512F-NEXT: vpmovdb %zmm0, %xmm0
1739 ; AVX512F-NEXT: kmovw %k0, %eax
1740 ; AVX512F-NEXT: testb $1, %al
1741 ; AVX512F-NEXT: je .LBB16_2
1742 ; AVX512F-NEXT: # %bb.1: # %cond.store
1743 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
1744 ; AVX512F-NEXT: .LBB16_2: # %else
1745 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1746 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1747 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1748 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1749 ; AVX512F-NEXT: kmovw %k0, %eax
1750 ; AVX512F-NEXT: testb $1, %al
1751 ; AVX512F-NEXT: je .LBB16_4
1752 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1753 ; AVX512F-NEXT: vpextrb $1, %xmm0, 1(%rdi)
1754 ; AVX512F-NEXT: .LBB16_4: # %else2
1755 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1756 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1757 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1758 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1759 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1760 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1761 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1762 ; AVX512F-NEXT: kmovw %k0, %eax
1763 ; AVX512F-NEXT: testb $1, %al
1764 ; AVX512F-NEXT: je .LBB16_6
1765 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1766 ; AVX512F-NEXT: vpextrb $2, %xmm0, 2(%rdi)
1767 ; AVX512F-NEXT: .LBB16_6: # %else4
1768 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1769 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1770 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1771 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1772 ; AVX512F-NEXT: kmovw %k0, %eax
1773 ; AVX512F-NEXT: testb $1, %al
1774 ; AVX512F-NEXT: je .LBB16_8
1775 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1776 ; AVX512F-NEXT: vpextrb $3, %xmm0, 3(%rdi)
1777 ; AVX512F-NEXT: .LBB16_8: # %else6
1778 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1779 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1780 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1781 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1782 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1783 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1784 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
1785 ; AVX512F-NEXT: kmovw %k0, %eax
1786 ; AVX512F-NEXT: testb $1, %al
1787 ; AVX512F-NEXT: je .LBB16_10
1788 ; AVX512F-NEXT: # %bb.9: # %cond.store7
1789 ; AVX512F-NEXT: vpextrb $4, %xmm0, 4(%rdi)
1790 ; AVX512F-NEXT: .LBB16_10: # %else8
1791 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1792 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1793 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1794 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
1795 ; AVX512F-NEXT: kmovw %k0, %eax
1796 ; AVX512F-NEXT: testb $1, %al
1797 ; AVX512F-NEXT: je .LBB16_12
1798 ; AVX512F-NEXT: # %bb.11: # %cond.store9
1799 ; AVX512F-NEXT: vpextrb $5, %xmm0, 5(%rdi)
1800 ; AVX512F-NEXT: .LBB16_12: # %else10
1801 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1802 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1803 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1804 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1805 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1806 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1807 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
1808 ; AVX512F-NEXT: kmovw %k0, %eax
1809 ; AVX512F-NEXT: testb $1, %al
1810 ; AVX512F-NEXT: je .LBB16_14
1811 ; AVX512F-NEXT: # %bb.13: # %cond.store11
1812 ; AVX512F-NEXT: vpextrb $6, %xmm0, 6(%rdi)
1813 ; AVX512F-NEXT: .LBB16_14: # %else12
1814 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1815 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1816 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1817 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
1818 ; AVX512F-NEXT: kmovw %k0, %eax
1819 ; AVX512F-NEXT: testb $1, %al
1820 ; AVX512F-NEXT: je .LBB16_16
1821 ; AVX512F-NEXT: # %bb.15: # %cond.store13
1822 ; AVX512F-NEXT: vpextrb $7, %xmm0, 7(%rdi)
1823 ; AVX512F-NEXT: .LBB16_16: # %else14
1824 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1825 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1826 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1827 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1828 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1829 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1830 ; AVX512F-NEXT: kshiftrw $8, %k0, %k0
1831 ; AVX512F-NEXT: kmovw %k0, %eax
1832 ; AVX512F-NEXT: testb $1, %al
1833 ; AVX512F-NEXT: je .LBB16_18
1834 ; AVX512F-NEXT: # %bb.17: # %cond.store15
1835 ; AVX512F-NEXT: vpextrb $8, %xmm0, 8(%rdi)
1836 ; AVX512F-NEXT: .LBB16_18: # %else16
1837 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1838 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1839 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1840 ; AVX512F-NEXT: kshiftrw $9, %k0, %k0
1841 ; AVX512F-NEXT: kmovw %k0, %eax
1842 ; AVX512F-NEXT: testb $1, %al
1843 ; AVX512F-NEXT: je .LBB16_20
1844 ; AVX512F-NEXT: # %bb.19: # %cond.store17
1845 ; AVX512F-NEXT: vpextrb $9, %xmm0, 9(%rdi)
1846 ; AVX512F-NEXT: .LBB16_20: # %else18
1847 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1848 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1849 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1850 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1851 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1852 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1853 ; AVX512F-NEXT: kshiftrw $10, %k0, %k0
1854 ; AVX512F-NEXT: kmovw %k0, %eax
1855 ; AVX512F-NEXT: testb $1, %al
1856 ; AVX512F-NEXT: je .LBB16_22
1857 ; AVX512F-NEXT: # %bb.21: # %cond.store19
1858 ; AVX512F-NEXT: vpextrb $10, %xmm0, 10(%rdi)
1859 ; AVX512F-NEXT: .LBB16_22: # %else20
1860 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1861 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1862 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1863 ; AVX512F-NEXT: kshiftrw $11, %k0, %k0
1864 ; AVX512F-NEXT: kmovw %k0, %eax
1865 ; AVX512F-NEXT: testb $1, %al
1866 ; AVX512F-NEXT: je .LBB16_24
1867 ; AVX512F-NEXT: # %bb.23: # %cond.store21
1868 ; AVX512F-NEXT: vpextrb $11, %xmm0, 11(%rdi)
1869 ; AVX512F-NEXT: .LBB16_24: # %else22
1870 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1871 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm2
1872 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1873 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1874 ; AVX512F-NEXT: vpmovsxbd %xmm3, %zmm3
1875 ; AVX512F-NEXT: vptestmd %zmm3, %zmm3, %k0
1876 ; AVX512F-NEXT: kshiftrw $12, %k0, %k0
1877 ; AVX512F-NEXT: kmovw %k0, %eax
1878 ; AVX512F-NEXT: testb $1, %al
1879 ; AVX512F-NEXT: je .LBB16_26
1880 ; AVX512F-NEXT: # %bb.25: # %cond.store23
1881 ; AVX512F-NEXT: vpextrb $12, %xmm0, 12(%rdi)
1882 ; AVX512F-NEXT: .LBB16_26: # %else24
1883 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1884 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1885 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1886 ; AVX512F-NEXT: kshiftrw $13, %k0, %k0
1887 ; AVX512F-NEXT: kmovw %k0, %eax
1888 ; AVX512F-NEXT: testb $1, %al
1889 ; AVX512F-NEXT: je .LBB16_28
1890 ; AVX512F-NEXT: # %bb.27: # %cond.store25
1891 ; AVX512F-NEXT: vpextrb $13, %xmm0, 13(%rdi)
1892 ; AVX512F-NEXT: .LBB16_28: # %else26
1893 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1894 ; AVX512F-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm1
1895 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm2
1896 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm2
1897 ; AVX512F-NEXT: vpmovsxbd %xmm2, %zmm2
1898 ; AVX512F-NEXT: vptestmd %zmm2, %zmm2, %k0
1899 ; AVX512F-NEXT: kshiftrw $14, %k0, %k0
1900 ; AVX512F-NEXT: kmovw %k0, %eax
1901 ; AVX512F-NEXT: testb $1, %al
1902 ; AVX512F-NEXT: je .LBB16_30
1903 ; AVX512F-NEXT: # %bb.29: # %cond.store27
1904 ; AVX512F-NEXT: vpextrb $14, %xmm0, 14(%rdi)
1905 ; AVX512F-NEXT: .LBB16_30: # %else28
1906 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
1907 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm1
1908 ; AVX512F-NEXT: vptestmd %zmm1, %zmm1, %k0
1909 ; AVX512F-NEXT: kshiftrw $15, %k0, %k0
1910 ; AVX512F-NEXT: kmovw %k0, %eax
1911 ; AVX512F-NEXT: testb $1, %al
1912 ; AVX512F-NEXT: je .LBB16_32
1913 ; AVX512F-NEXT: # %bb.31: # %cond.store29
1914 ; AVX512F-NEXT: vpextrb $15, %xmm0, 15(%rdi)
1915 ; AVX512F-NEXT: .LBB16_32: # %else30
1916 ; AVX512F-NEXT: vzeroupper
1917 ; AVX512F-NEXT: retq
1919 ; AVX512BW-LABEL: truncstore_v16i16_v16i8:
1920 ; AVX512BW: # %bb.0:
1921 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
1922 ; AVX512BW-NEXT: vptestmb %zmm1, %zmm1, %k0
1923 ; AVX512BW-NEXT: kmovw %k0, %k1
1924 ; AVX512BW-NEXT: vpminsw {{.*}}(%rip), %ymm0, %ymm0
1925 ; AVX512BW-NEXT: vpmaxsw {{.*}}(%rip), %ymm0, %ymm0
1926 ; AVX512BW-NEXT: vpmovwb %zmm0, %ymm0
1927 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
1928 ; AVX512BW-NEXT: vzeroupper
1929 ; AVX512BW-NEXT: retq
1931 ; AVX512BWVL-LABEL: truncstore_v16i16_v16i8:
1932 ; AVX512BWVL: # %bb.0:
1933 ; AVX512BWVL-NEXT: vptestmb %xmm1, %xmm1, %k1
1934 ; AVX512BWVL-NEXT: vpminsw {{.*}}(%rip), %ymm0, %ymm0
1935 ; AVX512BWVL-NEXT: vpmaxsw {{.*}}(%rip), %ymm0, %ymm0
1936 ; AVX512BWVL-NEXT: vpmovwb %ymm0, (%rdi) {%k1}
1937 ; AVX512BWVL-NEXT: vzeroupper
1938 ; AVX512BWVL-NEXT: retq
1939 %a = icmp ne <16 x i8> %mask, zeroinitializer
1940 %b = icmp slt <16 x i16> %x, <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
1941 %c = select <16 x i1> %b, <16 x i16> %x, <16 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
1942 %d = icmp sgt <16 x i16> %c, <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
1943 %e = select <16 x i1> %d, <16 x i16> %c, <16 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
1944 %f = trunc <16 x i16> %e to <16 x i8>
1945 call void @llvm.masked.store.v16i8.p0v16i8(<16 x i8> %f, <16 x i8>* %p, i32 1, <16 x i1> %a)
1949 define void @truncstore_v8i16_v8i8(<8 x i16> %x, <8 x i8>* %p, <8 x i16> %mask) {
1950 ; AVX512F-LABEL: truncstore_v8i16_v8i8:
1952 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1953 ; AVX512F-NEXT: vpcmpeqw %xmm2, %xmm1, %xmm2
1954 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1955 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1956 ; AVX512F-NEXT: vpmovsxwq %xmm3, %zmm3
1957 ; AVX512F-NEXT: vptestmq %zmm3, %zmm3, %k0
1958 ; AVX512F-NEXT: vpminsw {{.*}}(%rip), %xmm0, %xmm0
1959 ; AVX512F-NEXT: vpmaxsw {{.*}}(%rip), %xmm0, %xmm0
1960 ; AVX512F-NEXT: kmovw %k0, %eax
1961 ; AVX512F-NEXT: testb $1, %al
1962 ; AVX512F-NEXT: je .LBB17_2
1963 ; AVX512F-NEXT: # %bb.1: # %cond.store
1964 ; AVX512F-NEXT: vpextrb $0, %xmm0, (%rdi)
1965 ; AVX512F-NEXT: .LBB17_2: # %else
1966 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1967 ; AVX512F-NEXT: vpmovsxwq %xmm2, %zmm2
1968 ; AVX512F-NEXT: vptestmq %zmm2, %zmm2, %k0
1969 ; AVX512F-NEXT: kshiftrw $1, %k0, %k0
1970 ; AVX512F-NEXT: kmovw %k0, %eax
1971 ; AVX512F-NEXT: testb $1, %al
1972 ; AVX512F-NEXT: je .LBB17_4
1973 ; AVX512F-NEXT: # %bb.3: # %cond.store1
1974 ; AVX512F-NEXT: vpextrb $2, %xmm0, 1(%rdi)
1975 ; AVX512F-NEXT: .LBB17_4: # %else2
1976 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
1977 ; AVX512F-NEXT: vpcmpeqw %xmm2, %xmm1, %xmm2
1978 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
1979 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
1980 ; AVX512F-NEXT: vpmovsxwq %xmm3, %zmm3
1981 ; AVX512F-NEXT: vptestmq %zmm3, %zmm3, %k0
1982 ; AVX512F-NEXT: kshiftrw $2, %k0, %k0
1983 ; AVX512F-NEXT: kmovw %k0, %eax
1984 ; AVX512F-NEXT: testb $1, %al
1985 ; AVX512F-NEXT: je .LBB17_6
1986 ; AVX512F-NEXT: # %bb.5: # %cond.store3
1987 ; AVX512F-NEXT: vpextrb $4, %xmm0, 2(%rdi)
1988 ; AVX512F-NEXT: .LBB17_6: # %else4
1989 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
1990 ; AVX512F-NEXT: vpmovsxwq %xmm2, %zmm2
1991 ; AVX512F-NEXT: vptestmq %zmm2, %zmm2, %k0
1992 ; AVX512F-NEXT: kshiftrw $3, %k0, %k0
1993 ; AVX512F-NEXT: kmovw %k0, %eax
1994 ; AVX512F-NEXT: testb $1, %al
1995 ; AVX512F-NEXT: je .LBB17_8
1996 ; AVX512F-NEXT: # %bb.7: # %cond.store5
1997 ; AVX512F-NEXT: vpextrb $6, %xmm0, 3(%rdi)
1998 ; AVX512F-NEXT: .LBB17_8: # %else6
1999 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
2000 ; AVX512F-NEXT: vpcmpeqw %xmm2, %xmm1, %xmm2
2001 ; AVX512F-NEXT: vmovdqa64 %zmm2, %zmm3
2002 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm3
2003 ; AVX512F-NEXT: vpmovsxwq %xmm3, %zmm3
2004 ; AVX512F-NEXT: vptestmq %zmm3, %zmm3, %k0
2005 ; AVX512F-NEXT: kshiftrw $4, %k0, %k0
2006 ; AVX512F-NEXT: kmovw %k0, %eax
2007 ; AVX512F-NEXT: testb $1, %al
2008 ; AVX512F-NEXT: je .LBB17_10
2009 ; AVX512F-NEXT: # %bb.9: # %cond.store7
2010 ; AVX512F-NEXT: vpextrb $8, %xmm0, 4(%rdi)
2011 ; AVX512F-NEXT: .LBB17_10: # %else8
2012 ; AVX512F-NEXT: vpternlogq $15, %zmm2, %zmm2, %zmm2
2013 ; AVX512F-NEXT: vpmovsxwq %xmm2, %zmm2
2014 ; AVX512F-NEXT: vptestmq %zmm2, %zmm2, %k0
2015 ; AVX512F-NEXT: kshiftrw $5, %k0, %k0
2016 ; AVX512F-NEXT: kmovw %k0, %eax
2017 ; AVX512F-NEXT: testb $1, %al
2018 ; AVX512F-NEXT: je .LBB17_12
2019 ; AVX512F-NEXT: # %bb.11: # %cond.store9
2020 ; AVX512F-NEXT: vpextrb $10, %xmm0, 5(%rdi)
2021 ; AVX512F-NEXT: .LBB17_12: # %else10
2022 ; AVX512F-NEXT: vpxor %xmm2, %xmm2, %xmm2
2023 ; AVX512F-NEXT: vpcmpeqw %xmm2, %xmm1, %xmm1
2024 ; AVX512F-NEXT: vmovdqa64 %zmm1, %zmm2
2025 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm2
2026 ; AVX512F-NEXT: vpmovsxwq %xmm2, %zmm2
2027 ; AVX512F-NEXT: vptestmq %zmm2, %zmm2, %k0
2028 ; AVX512F-NEXT: kshiftrw $6, %k0, %k0
2029 ; AVX512F-NEXT: kmovw %k0, %eax
2030 ; AVX512F-NEXT: testb $1, %al
2031 ; AVX512F-NEXT: je .LBB17_14
2032 ; AVX512F-NEXT: # %bb.13: # %cond.store11
2033 ; AVX512F-NEXT: vpextrb $12, %xmm0, 6(%rdi)
2034 ; AVX512F-NEXT: .LBB17_14: # %else12
2035 ; AVX512F-NEXT: vpternlogq $15, %zmm1, %zmm1, %zmm1
2036 ; AVX512F-NEXT: vpmovsxwq %xmm1, %zmm1
2037 ; AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k0
2038 ; AVX512F-NEXT: kshiftrw $7, %k0, %k0
2039 ; AVX512F-NEXT: kmovw %k0, %eax
2040 ; AVX512F-NEXT: testb $1, %al
2041 ; AVX512F-NEXT: je .LBB17_16
2042 ; AVX512F-NEXT: # %bb.15: # %cond.store13
2043 ; AVX512F-NEXT: vpextrb $14, %xmm0, 7(%rdi)
2044 ; AVX512F-NEXT: .LBB17_16: # %else14
2045 ; AVX512F-NEXT: vzeroupper
2046 ; AVX512F-NEXT: retq
2048 ; AVX512BW-LABEL: truncstore_v8i16_v8i8:
2049 ; AVX512BW: # %bb.0:
2050 ; AVX512BW-NEXT: # kill: def $xmm1 killed $xmm1 def $zmm1
2051 ; AVX512BW-NEXT: vptestmw %zmm1, %zmm1, %k0
2052 ; AVX512BW-NEXT: vpminsw {{.*}}(%rip), %xmm0, %xmm0
2053 ; AVX512BW-NEXT: vpmaxsw {{.*}}(%rip), %xmm0, %xmm0
2054 ; AVX512BW-NEXT: vpacksswb %xmm0, %xmm0, %xmm0
2055 ; AVX512BW-NEXT: kshiftlq $56, %k0, %k0
2056 ; AVX512BW-NEXT: kshiftrq $56, %k0, %k1
2057 ; AVX512BW-NEXT: vmovdqu8 %zmm0, (%rdi) {%k1}
2058 ; AVX512BW-NEXT: vzeroupper
2059 ; AVX512BW-NEXT: retq
2061 ; AVX512BWVL-LABEL: truncstore_v8i16_v8i8:
2062 ; AVX512BWVL: # %bb.0:
2063 ; AVX512BWVL-NEXT: vptestmw %xmm1, %xmm1, %k1
2064 ; AVX512BWVL-NEXT: vpminsw {{.*}}(%rip), %xmm0, %xmm0
2065 ; AVX512BWVL-NEXT: vpmaxsw {{.*}}(%rip), %xmm0, %xmm0
2066 ; AVX512BWVL-NEXT: vpmovwb %xmm0, (%rdi) {%k1}
2067 ; AVX512BWVL-NEXT: retq
2068 %a = icmp ne <8 x i16> %mask, zeroinitializer
2069 %b = icmp slt <8 x i16> %x, <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
2070 %c = select <8 x i1> %b, <8 x i16> %x, <8 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
2071 %d = icmp sgt <8 x i16> %c, <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
2072 %e = select <8 x i1> %d, <8 x i16> %c, <8 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
2073 %f = trunc <8 x i16> %e to <8 x i8>
2074 call void @llvm.masked.store.v8i8.p0v8i8(<8 x i8> %f, <8 x i8>* %p, i32 1, <8 x i1> %a)
2078 declare void @llvm.masked.store.v8i32.p0v8i32(<8 x i32>, <8 x i32>*, i32, <8 x i1>)
2079 declare void @llvm.masked.store.v8i16.p0v8i16(<8 x i16>, <8 x i16>*, i32, <8 x i1>)
2080 declare void @llvm.masked.store.v8i8.p0v8i8(<8 x i8>, <8 x i8>*, i32, <8 x i1>)
2081 declare void @llvm.masked.store.v4i32.p0v4i32(<4 x i32>, <4 x i32>*, i32, <4 x i1>)
2082 declare void @llvm.masked.store.v4i16.p0v4i16(<4 x i16>, <4 x i16>*, i32, <4 x i1>)
2083 declare void @llvm.masked.store.v4i8.p0v4i8(<4 x i8>, <4 x i8>*, i32, <4 x i1>)
2084 declare void @llvm.masked.store.v2i32.p0v2i32(<2 x i32>, <2 x i32>*, i32, <2 x i1>)
2085 declare void @llvm.masked.store.v2i16.p0v2i16(<2 x i16>, <2 x i16>*, i32, <2 x i1>)
2086 declare void @llvm.masked.store.v2i8.p0v2i8(<2 x i8>, <2 x i8>*, i32, <2 x i1>)
2087 declare void @llvm.masked.store.v16i16.p0v16i16(<16 x i16>, <16 x i16>*, i32, <16 x i1>)
2088 declare void @llvm.masked.store.v16i8.p0v16i8(<16 x i8>, <16 x i8>*, i32, <16 x i1>)
2089 declare void @llvm.masked.store.v32i8.p0v32i8(<32 x i8>, <32 x i8>*, i32, <32 x i1>)