1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X86,X86-AVX512F
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64-AVX512F
4 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=avx512bw | FileCheck %s --check-prefixes=X86,X86-AVX512BW
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512bw | FileCheck %s --check-prefixes=X64,X64-AVX512BW
7 define <16 x i32> @select00(i32 %a, <16 x i32> %b) nounwind {
10 ; X86-NEXT: cmpl $255, {{[0-9]+}}(%esp)
11 ; X86-NEXT: vpxor %xmm1, %xmm1, %xmm1
12 ; X86-NEXT: je .LBB0_2
14 ; X86-NEXT: vmovdqa64 %zmm0, %zmm1
16 ; X86-NEXT: vpxord %zmm1, %zmm0, %zmm0
19 ; X64-LABEL: select00:
21 ; X64-NEXT: cmpl $255, %edi
22 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
23 ; X64-NEXT: je .LBB0_2
25 ; X64-NEXT: vmovdqa64 %zmm0, %zmm1
27 ; X64-NEXT: vpxord %zmm1, %zmm0, %zmm0
29 %cmpres = icmp eq i32 %a, 255
30 %selres = select i1 %cmpres, <16 x i32> zeroinitializer, <16 x i32> %b
31 %res = xor <16 x i32> %b, %selres
35 define <8 x i64> @select01(i32 %a, <8 x i64> %b) nounwind {
36 ; X86-LABEL: select01:
38 ; X86-NEXT: cmpl $255, {{[0-9]+}}(%esp)
39 ; X86-NEXT: vpxor %xmm1, %xmm1, %xmm1
40 ; X86-NEXT: je .LBB1_2
42 ; X86-NEXT: vmovdqa64 %zmm0, %zmm1
44 ; X86-NEXT: vpxorq %zmm1, %zmm0, %zmm0
47 ; X64-LABEL: select01:
49 ; X64-NEXT: cmpl $255, %edi
50 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
51 ; X64-NEXT: je .LBB1_2
53 ; X64-NEXT: vmovdqa64 %zmm0, %zmm1
55 ; X64-NEXT: vpxorq %zmm1, %zmm0, %zmm0
57 %cmpres = icmp eq i32 %a, 255
58 %selres = select i1 %cmpres, <8 x i64> zeroinitializer, <8 x i64> %b
59 %res = xor <8 x i64> %b, %selres
63 define float @select02(float %a, float %b, float %c, float %eps) {
64 ; X86-LABEL: select02:
66 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
67 ; X86-NEXT: vucomiss {{[0-9]+}}(%esp), %xmm0
68 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
69 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
70 ; X86-NEXT: cmovael %eax, %ecx
71 ; X86-NEXT: flds (%ecx)
74 ; X64-LABEL: select02:
76 ; X64-NEXT: vcmpless %xmm0, %xmm3, %k1
77 ; X64-NEXT: vmovss %xmm2, %xmm0, %xmm1 {%k1}
78 ; X64-NEXT: vmovaps %xmm1, %xmm0
80 %cmp = fcmp oge float %a, %eps
81 %cond = select i1 %cmp, float %c, float %b
85 define double @select03(double %a, double %b, double %c, double %eps) {
86 ; X86-LABEL: select03:
88 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
89 ; X86-NEXT: vucomisd {{[0-9]+}}(%esp), %xmm0
90 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
91 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
92 ; X86-NEXT: cmovael %eax, %ecx
93 ; X86-NEXT: fldl (%ecx)
96 ; X64-LABEL: select03:
98 ; X64-NEXT: vcmplesd %xmm0, %xmm3, %k1
99 ; X64-NEXT: vmovsd %xmm2, %xmm0, %xmm1 {%k1}
100 ; X64-NEXT: vmovapd %xmm1, %xmm0
102 %cmp = fcmp oge double %a, %eps
103 %cond = select i1 %cmp, double %c, double %b
107 define <16 x double> @select04(<16 x double> %a, <16 x double> %b) {
108 ; X86-LABEL: select04:
110 ; X86-NEXT: pushl %ebp
111 ; X86-NEXT: .cfi_def_cfa_offset 8
112 ; X86-NEXT: .cfi_offset %ebp, -8
113 ; X86-NEXT: movl %esp, %ebp
114 ; X86-NEXT: .cfi_def_cfa_register %ebp
115 ; X86-NEXT: andl $-64, %esp
116 ; X86-NEXT: subl $64, %esp
117 ; X86-NEXT: vmovaps 8(%ebp), %zmm1
118 ; X86-NEXT: movl %ebp, %esp
119 ; X86-NEXT: popl %ebp
120 ; X86-NEXT: .cfi_def_cfa %esp, 4
123 ; X64-LABEL: select04:
125 ; X64-NEXT: vmovaps %zmm3, %zmm1
127 %sel = select <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <16 x double> %a, <16 x double> %b
128 ret <16 x double> %sel
131 define i8 @select05(i8 %a.0, i8 %m) {
132 ; X86-LABEL: select05:
134 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
135 ; X86-NEXT: orb {{[0-9]+}}(%esp), %al
138 ; X64-LABEL: select05:
140 ; X64-NEXT: movl %edi, %eax
141 ; X64-NEXT: orl %esi, %eax
142 ; X64-NEXT: # kill: def $al killed $al killed $eax
144 %mask = bitcast i8 %m to <8 x i1>
145 %a = bitcast i8 %a.0 to <8 x i1>
146 %r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
147 %res = bitcast <8 x i1> %r to i8
151 define i8 @select05_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
152 ; X86-AVX512F-LABEL: select05_mem:
153 ; X86-AVX512F: # %bb.0:
154 ; X86-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %eax
155 ; X86-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %ecx
156 ; X86-AVX512F-NEXT: kmovw (%ecx), %k0
157 ; X86-AVX512F-NEXT: kmovw (%eax), %k1
158 ; X86-AVX512F-NEXT: korw %k1, %k0, %k0
159 ; X86-AVX512F-NEXT: kmovw %k0, %eax
160 ; X86-AVX512F-NEXT: # kill: def $al killed $al killed $eax
161 ; X86-AVX512F-NEXT: retl
163 ; X64-AVX512F-LABEL: select05_mem:
164 ; X64-AVX512F: # %bb.0:
165 ; X64-AVX512F-NEXT: kmovw (%rsi), %k0
166 ; X64-AVX512F-NEXT: kmovw (%rdi), %k1
167 ; X64-AVX512F-NEXT: korw %k1, %k0, %k0
168 ; X64-AVX512F-NEXT: kmovw %k0, %eax
169 ; X64-AVX512F-NEXT: # kill: def $al killed $al killed $eax
170 ; X64-AVX512F-NEXT: retq
172 ; X86-AVX512BW-LABEL: select05_mem:
173 ; X86-AVX512BW: # %bb.0:
174 ; X86-AVX512BW-NEXT: movl {{[0-9]+}}(%esp), %eax
175 ; X86-AVX512BW-NEXT: movl {{[0-9]+}}(%esp), %ecx
176 ; X86-AVX512BW-NEXT: kmovw (%ecx), %k0
177 ; X86-AVX512BW-NEXT: kmovw (%eax), %k1
178 ; X86-AVX512BW-NEXT: korw %k1, %k0, %k0
179 ; X86-AVX512BW-NEXT: kmovd %k0, %eax
180 ; X86-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
181 ; X86-AVX512BW-NEXT: retl
183 ; X64-AVX512BW-LABEL: select05_mem:
184 ; X64-AVX512BW: # %bb.0:
185 ; X64-AVX512BW-NEXT: kmovw (%rsi), %k0
186 ; X64-AVX512BW-NEXT: kmovw (%rdi), %k1
187 ; X64-AVX512BW-NEXT: korw %k1, %k0, %k0
188 ; X64-AVX512BW-NEXT: kmovd %k0, %eax
189 ; X64-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
190 ; X64-AVX512BW-NEXT: retq
191 %mask = load <8 x i1> , <8 x i1>* %m
192 %a = load <8 x i1> , <8 x i1>* %a.0
193 %r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
194 %res = bitcast <8 x i1> %r to i8
198 define i8 @select06(i8 %a.0, i8 %m) {
199 ; X86-LABEL: select06:
201 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
202 ; X86-NEXT: andb {{[0-9]+}}(%esp), %al
205 ; X64-LABEL: select06:
207 ; X64-NEXT: movl %edi, %eax
208 ; X64-NEXT: andl %esi, %eax
209 ; X64-NEXT: # kill: def $al killed $al killed $eax
211 %mask = bitcast i8 %m to <8 x i1>
212 %a = bitcast i8 %a.0 to <8 x i1>
213 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
214 %res = bitcast <8 x i1> %r to i8
218 define i8 @select06_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
219 ; X86-AVX512F-LABEL: select06_mem:
220 ; X86-AVX512F: # %bb.0:
221 ; X86-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %eax
222 ; X86-AVX512F-NEXT: movl {{[0-9]+}}(%esp), %ecx
223 ; X86-AVX512F-NEXT: kmovw (%ecx), %k0
224 ; X86-AVX512F-NEXT: kmovw (%eax), %k1
225 ; X86-AVX512F-NEXT: kandw %k1, %k0, %k0
226 ; X86-AVX512F-NEXT: kmovw %k0, %eax
227 ; X86-AVX512F-NEXT: # kill: def $al killed $al killed $eax
228 ; X86-AVX512F-NEXT: retl
230 ; X64-AVX512F-LABEL: select06_mem:
231 ; X64-AVX512F: # %bb.0:
232 ; X64-AVX512F-NEXT: kmovw (%rsi), %k0
233 ; X64-AVX512F-NEXT: kmovw (%rdi), %k1
234 ; X64-AVX512F-NEXT: kandw %k1, %k0, %k0
235 ; X64-AVX512F-NEXT: kmovw %k0, %eax
236 ; X64-AVX512F-NEXT: # kill: def $al killed $al killed $eax
237 ; X64-AVX512F-NEXT: retq
239 ; X86-AVX512BW-LABEL: select06_mem:
240 ; X86-AVX512BW: # %bb.0:
241 ; X86-AVX512BW-NEXT: movl {{[0-9]+}}(%esp), %eax
242 ; X86-AVX512BW-NEXT: movl {{[0-9]+}}(%esp), %ecx
243 ; X86-AVX512BW-NEXT: kmovw (%ecx), %k0
244 ; X86-AVX512BW-NEXT: kmovw (%eax), %k1
245 ; X86-AVX512BW-NEXT: kandw %k1, %k0, %k0
246 ; X86-AVX512BW-NEXT: kmovd %k0, %eax
247 ; X86-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
248 ; X86-AVX512BW-NEXT: retl
250 ; X64-AVX512BW-LABEL: select06_mem:
251 ; X64-AVX512BW: # %bb.0:
252 ; X64-AVX512BW-NEXT: kmovw (%rsi), %k0
253 ; X64-AVX512BW-NEXT: kmovw (%rdi), %k1
254 ; X64-AVX512BW-NEXT: kandw %k1, %k0, %k0
255 ; X64-AVX512BW-NEXT: kmovd %k0, %eax
256 ; X64-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
257 ; X64-AVX512BW-NEXT: retq
258 %mask = load <8 x i1> , <8 x i1>* %m
259 %a = load <8 x i1> , <8 x i1>* %a.0
260 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
261 %res = bitcast <8 x i1> %r to i8
264 define i8 @select07(i8 %a.0, i8 %b.0, i8 %m) {
265 ; X86-AVX512F-LABEL: select07:
266 ; X86-AVX512F: # %bb.0:
267 ; X86-AVX512F-NEXT: movzbl {{[0-9]+}}(%esp), %eax
268 ; X86-AVX512F-NEXT: kmovw %eax, %k0
269 ; X86-AVX512F-NEXT: movzbl {{[0-9]+}}(%esp), %eax
270 ; X86-AVX512F-NEXT: kmovw %eax, %k1
271 ; X86-AVX512F-NEXT: movzbl {{[0-9]+}}(%esp), %eax
272 ; X86-AVX512F-NEXT: kmovw %eax, %k2
273 ; X86-AVX512F-NEXT: kandnw %k2, %k0, %k2
274 ; X86-AVX512F-NEXT: kandw %k0, %k1, %k0
275 ; X86-AVX512F-NEXT: korw %k2, %k0, %k0
276 ; X86-AVX512F-NEXT: kmovw %k0, %eax
277 ; X86-AVX512F-NEXT: # kill: def $al killed $al killed $eax
278 ; X86-AVX512F-NEXT: retl
280 ; X64-AVX512F-LABEL: select07:
281 ; X64-AVX512F: # %bb.0:
282 ; X64-AVX512F-NEXT: kmovw %edx, %k0
283 ; X64-AVX512F-NEXT: kmovw %edi, %k1
284 ; X64-AVX512F-NEXT: kmovw %esi, %k2
285 ; X64-AVX512F-NEXT: kandnw %k2, %k0, %k2
286 ; X64-AVX512F-NEXT: kandw %k0, %k1, %k0
287 ; X64-AVX512F-NEXT: korw %k2, %k0, %k0
288 ; X64-AVX512F-NEXT: kmovw %k0, %eax
289 ; X64-AVX512F-NEXT: # kill: def $al killed $al killed $eax
290 ; X64-AVX512F-NEXT: retq
292 ; X86-AVX512BW-LABEL: select07:
293 ; X86-AVX512BW: # %bb.0:
294 ; X86-AVX512BW-NEXT: movzbl {{[0-9]+}}(%esp), %eax
295 ; X86-AVX512BW-NEXT: kmovd %eax, %k0
296 ; X86-AVX512BW-NEXT: movzbl {{[0-9]+}}(%esp), %eax
297 ; X86-AVX512BW-NEXT: kmovd %eax, %k1
298 ; X86-AVX512BW-NEXT: movzbl {{[0-9]+}}(%esp), %eax
299 ; X86-AVX512BW-NEXT: kmovd %eax, %k2
300 ; X86-AVX512BW-NEXT: kandnw %k2, %k0, %k2
301 ; X86-AVX512BW-NEXT: kandw %k0, %k1, %k0
302 ; X86-AVX512BW-NEXT: korw %k2, %k0, %k0
303 ; X86-AVX512BW-NEXT: kmovd %k0, %eax
304 ; X86-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
305 ; X86-AVX512BW-NEXT: retl
307 ; X64-AVX512BW-LABEL: select07:
308 ; X64-AVX512BW: # %bb.0:
309 ; X64-AVX512BW-NEXT: kmovd %edx, %k0
310 ; X64-AVX512BW-NEXT: kmovd %edi, %k1
311 ; X64-AVX512BW-NEXT: kmovd %esi, %k2
312 ; X64-AVX512BW-NEXT: kandnw %k2, %k0, %k2
313 ; X64-AVX512BW-NEXT: kandw %k0, %k1, %k0
314 ; X64-AVX512BW-NEXT: korw %k2, %k0, %k0
315 ; X64-AVX512BW-NEXT: kmovd %k0, %eax
316 ; X64-AVX512BW-NEXT: # kill: def $al killed $al killed $eax
317 ; X64-AVX512BW-NEXT: retq
318 %mask = bitcast i8 %m to <8 x i1>
319 %a = bitcast i8 %a.0 to <8 x i1>
320 %b = bitcast i8 %b.0 to <8 x i1>
321 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> %b
322 %res = bitcast <8 x i1> %r to i8
326 define i64 @pr30249() {
327 ; X86-LABEL: pr30249:
329 ; X86-NEXT: movl $1, %eax
330 ; X86-NEXT: xorl %edx, %edx
333 ; X64-LABEL: pr30249:
335 ; X64-NEXT: movl $1, %eax
337 %v = select i1 undef , i64 1, i64 2
341 define double @pr30561_f64(double %b, double %a, i1 %c) {
342 ; X86-LABEL: pr30561_f64:
344 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
345 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
346 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
347 ; X86-NEXT: cmovnel %eax, %ecx
348 ; X86-NEXT: fldl (%ecx)
351 ; X64-AVX512F-LABEL: pr30561_f64:
352 ; X64-AVX512F: # %bb.0:
353 ; X64-AVX512F-NEXT: kmovw %edi, %k1
354 ; X64-AVX512F-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
355 ; X64-AVX512F-NEXT: retq
357 ; X64-AVX512BW-LABEL: pr30561_f64:
358 ; X64-AVX512BW: # %bb.0:
359 ; X64-AVX512BW-NEXT: kmovd %edi, %k1
360 ; X64-AVX512BW-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
361 ; X64-AVX512BW-NEXT: retq
362 %cond = select i1 %c, double %a, double %b
366 define float @pr30561_f32(float %b, float %a, i1 %c) {
367 ; X86-LABEL: pr30561_f32:
369 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
370 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
371 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
372 ; X86-NEXT: cmovnel %eax, %ecx
373 ; X86-NEXT: flds (%ecx)
376 ; X64-AVX512F-LABEL: pr30561_f32:
377 ; X64-AVX512F: # %bb.0:
378 ; X64-AVX512F-NEXT: kmovw %edi, %k1
379 ; X64-AVX512F-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
380 ; X64-AVX512F-NEXT: retq
382 ; X64-AVX512BW-LABEL: pr30561_f32:
383 ; X64-AVX512BW: # %bb.0:
384 ; X64-AVX512BW-NEXT: kmovd %edi, %k1
385 ; X64-AVX512BW-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
386 ; X64-AVX512BW-NEXT: retq
387 %cond = select i1 %c, float %a, float %b
391 define <16 x i16> @pr31515(<16 x i1> %a, <16 x i1> %b, <16 x i16> %c) nounwind {
392 ; X86-AVX512F-LABEL: pr31515:
393 ; X86-AVX512F: # %bb.0:
394 ; X86-AVX512F-NEXT: vpand %xmm1, %xmm0, %xmm0
395 ; X86-AVX512F-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
396 ; X86-AVX512F-NEXT: vpsllw $15, %ymm0, %ymm0
397 ; X86-AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0
398 ; X86-AVX512F-NEXT: vpandn %ymm2, %ymm0, %ymm0
399 ; X86-AVX512F-NEXT: retl
401 ; X64-AVX512F-LABEL: pr31515:
402 ; X64-AVX512F: # %bb.0:
403 ; X64-AVX512F-NEXT: vpand %xmm1, %xmm0, %xmm0
404 ; X64-AVX512F-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
405 ; X64-AVX512F-NEXT: vpsllw $15, %ymm0, %ymm0
406 ; X64-AVX512F-NEXT: vpsraw $15, %ymm0, %ymm0
407 ; X64-AVX512F-NEXT: vpandn %ymm2, %ymm0, %ymm0
408 ; X64-AVX512F-NEXT: retq
410 ; X86-AVX512BW-LABEL: pr31515:
411 ; X86-AVX512BW: # %bb.0:
412 ; X86-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
413 ; X86-AVX512BW-NEXT: vpand %xmm1, %xmm0, %xmm0
414 ; X86-AVX512BW-NEXT: vpsllw $7, %xmm0, %xmm0
415 ; X86-AVX512BW-NEXT: vpmovb2m %zmm0, %k0
416 ; X86-AVX512BW-NEXT: knotw %k0, %k1
417 ; X86-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm0 {%k1} {z}
418 ; X86-AVX512BW-NEXT: # kill: def $ymm0 killed $ymm0 killed $zmm0
419 ; X86-AVX512BW-NEXT: retl
421 ; X64-AVX512BW-LABEL: pr31515:
422 ; X64-AVX512BW: # %bb.0:
423 ; X64-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
424 ; X64-AVX512BW-NEXT: vpand %xmm1, %xmm0, %xmm0
425 ; X64-AVX512BW-NEXT: vpsllw $7, %xmm0, %xmm0
426 ; X64-AVX512BW-NEXT: vpmovb2m %zmm0, %k0
427 ; X64-AVX512BW-NEXT: knotw %k0, %k1
428 ; X64-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm0 {%k1} {z}
429 ; X64-AVX512BW-NEXT: # kill: def $ymm0 killed $ymm0 killed $zmm0
430 ; X64-AVX512BW-NEXT: retq
431 %mask = and <16 x i1> %a, %b
432 %res = select <16 x i1> %mask, <16 x i16> zeroinitializer, <16 x i16> %c
436 define <32 x i16> @pr42355_v32i16(i1 %c, <32 x i16> %x, <32 x i16> %y) {
437 ; X86-AVX512F-LABEL: pr42355_v32i16:
438 ; X86-AVX512F: # %bb.0:
439 ; X86-AVX512F-NEXT: testb $1, {{[0-9]+}}(%esp)
440 ; X86-AVX512F-NEXT: jne .LBB14_1
441 ; X86-AVX512F-NEXT: # %bb.2:
442 ; X86-AVX512F-NEXT: vextractf64x4 $1, %zmm1, %ymm2
443 ; X86-AVX512F-NEXT: vmovaps %ymm1, %ymm0
444 ; X86-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
445 ; X86-AVX512F-NEXT: retl
446 ; X86-AVX512F-NEXT: .LBB14_1:
447 ; X86-AVX512F-NEXT: vextractf64x4 $1, %zmm0, %ymm2
448 ; X86-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
449 ; X86-AVX512F-NEXT: retl
451 ; X64-AVX512F-LABEL: pr42355_v32i16:
452 ; X64-AVX512F: # %bb.0:
453 ; X64-AVX512F-NEXT: testb $1, %dil
454 ; X64-AVX512F-NEXT: jne .LBB14_1
455 ; X64-AVX512F-NEXT: # %bb.2:
456 ; X64-AVX512F-NEXT: vextractf64x4 $1, %zmm1, %ymm2
457 ; X64-AVX512F-NEXT: vmovaps %ymm1, %ymm0
458 ; X64-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
459 ; X64-AVX512F-NEXT: retq
460 ; X64-AVX512F-NEXT: .LBB14_1:
461 ; X64-AVX512F-NEXT: vextractf64x4 $1, %zmm0, %ymm2
462 ; X64-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
463 ; X64-AVX512F-NEXT: retq
465 ; X86-AVX512BW-LABEL: pr42355_v32i16:
466 ; X86-AVX512BW: # %bb.0:
467 ; X86-AVX512BW-NEXT: testb $1, {{[0-9]+}}(%esp)
468 ; X86-AVX512BW-NEXT: jne .LBB14_2
469 ; X86-AVX512BW-NEXT: # %bb.1:
470 ; X86-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
471 ; X86-AVX512BW-NEXT: .LBB14_2:
472 ; X86-AVX512BW-NEXT: retl
474 ; X64-AVX512BW-LABEL: pr42355_v32i16:
475 ; X64-AVX512BW: # %bb.0:
476 ; X64-AVX512BW-NEXT: testb $1, %dil
477 ; X64-AVX512BW-NEXT: jne .LBB14_2
478 ; X64-AVX512BW-NEXT: # %bb.1:
479 ; X64-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
480 ; X64-AVX512BW-NEXT: .LBB14_2:
481 ; X64-AVX512BW-NEXT: retq
482 %a = select i1 %c, <32 x i16> %x, <32 x i16> %y
486 define <64 x i8> @pr42355_v64i8(i1 %c, <64 x i8> %x, <64 x i8> %y) {
487 ; X86-AVX512F-LABEL: pr42355_v64i8:
488 ; X86-AVX512F: # %bb.0:
489 ; X86-AVX512F-NEXT: testb $1, {{[0-9]+}}(%esp)
490 ; X86-AVX512F-NEXT: jne .LBB15_1
491 ; X86-AVX512F-NEXT: # %bb.2:
492 ; X86-AVX512F-NEXT: vextractf64x4 $1, %zmm1, %ymm2
493 ; X86-AVX512F-NEXT: vmovaps %ymm1, %ymm0
494 ; X86-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
495 ; X86-AVX512F-NEXT: retl
496 ; X86-AVX512F-NEXT: .LBB15_1:
497 ; X86-AVX512F-NEXT: vextractf64x4 $1, %zmm0, %ymm2
498 ; X86-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
499 ; X86-AVX512F-NEXT: retl
501 ; X64-AVX512F-LABEL: pr42355_v64i8:
502 ; X64-AVX512F: # %bb.0:
503 ; X64-AVX512F-NEXT: testb $1, %dil
504 ; X64-AVX512F-NEXT: jne .LBB15_1
505 ; X64-AVX512F-NEXT: # %bb.2:
506 ; X64-AVX512F-NEXT: vextractf64x4 $1, %zmm1, %ymm2
507 ; X64-AVX512F-NEXT: vmovaps %ymm1, %ymm0
508 ; X64-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
509 ; X64-AVX512F-NEXT: retq
510 ; X64-AVX512F-NEXT: .LBB15_1:
511 ; X64-AVX512F-NEXT: vextractf64x4 $1, %zmm0, %ymm2
512 ; X64-AVX512F-NEXT: vinsertf64x4 $1, %ymm2, %zmm0, %zmm0
513 ; X64-AVX512F-NEXT: retq
515 ; X86-AVX512BW-LABEL: pr42355_v64i8:
516 ; X86-AVX512BW: # %bb.0:
517 ; X86-AVX512BW-NEXT: testb $1, {{[0-9]+}}(%esp)
518 ; X86-AVX512BW-NEXT: jne .LBB15_2
519 ; X86-AVX512BW-NEXT: # %bb.1:
520 ; X86-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
521 ; X86-AVX512BW-NEXT: .LBB15_2:
522 ; X86-AVX512BW-NEXT: retl
524 ; X64-AVX512BW-LABEL: pr42355_v64i8:
525 ; X64-AVX512BW: # %bb.0:
526 ; X64-AVX512BW-NEXT: testb $1, %dil
527 ; X64-AVX512BW-NEXT: jne .LBB15_2
528 ; X64-AVX512BW-NEXT: # %bb.1:
529 ; X64-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
530 ; X64-AVX512BW-NEXT: .LBB15_2:
531 ; X64-AVX512BW-NEXT: retq
532 %a = select i1 %c, <64 x i8> %x, <64 x i8> %y
536 ; This would crash because AVX512 has legal vector select
537 ; condition values that are not 256/512-bit vectors.
539 define <16 x i64> @narrowExtractedVectorSelect_crash(<16 x i64> %arg, <16 x i16> %arg1) #0 {
540 ; X86-AVX512F-LABEL: narrowExtractedVectorSelect_crash:
541 ; X86-AVX512F: # %bb.0:
542 ; X86-AVX512F-NEXT: vptestmq %zmm0, %zmm0, %k0
543 ; X86-AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k1
544 ; X86-AVX512F-NEXT: kunpckbw %k0, %k1, %k1
545 ; X86-AVX512F-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
546 ; X86-AVX512F-NEXT: vpmovdw %zmm0, %ymm0
547 ; X86-AVX512F-NEXT: vpand %ymm2, %ymm0, %ymm1
548 ; X86-AVX512F-NEXT: vpmovzxwq {{.*#+}} zmm0 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
549 ; X86-AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
550 ; X86-AVX512F-NEXT: vpmovzxwq {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
551 ; X86-AVX512F-NEXT: retl
553 ; X64-AVX512F-LABEL: narrowExtractedVectorSelect_crash:
554 ; X64-AVX512F: # %bb.0:
555 ; X64-AVX512F-NEXT: vptestmq %zmm0, %zmm0, %k0
556 ; X64-AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k1
557 ; X64-AVX512F-NEXT: kunpckbw %k0, %k1, %k1
558 ; X64-AVX512F-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
559 ; X64-AVX512F-NEXT: vpmovdw %zmm0, %ymm0
560 ; X64-AVX512F-NEXT: vpand %ymm2, %ymm0, %ymm1
561 ; X64-AVX512F-NEXT: vpmovzxwq {{.*#+}} zmm0 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
562 ; X64-AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
563 ; X64-AVX512F-NEXT: vpmovzxwq {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
564 ; X64-AVX512F-NEXT: retq
566 ; X86-AVX512BW-LABEL: narrowExtractedVectorSelect_crash:
567 ; X86-AVX512BW: # %bb.0:
568 ; X86-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
569 ; X86-AVX512BW-NEXT: vptestmq %zmm0, %zmm0, %k0
570 ; X86-AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k1
571 ; X86-AVX512BW-NEXT: kunpckbw %k0, %k1, %k1
572 ; X86-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm1 {%k1} {z}
573 ; X86-AVX512BW-NEXT: vpmovzxwq {{.*#+}} zmm0 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
574 ; X86-AVX512BW-NEXT: vextracti128 $1, %ymm1, %xmm1
575 ; X86-AVX512BW-NEXT: vpmovzxwq {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
576 ; X86-AVX512BW-NEXT: retl
578 ; X64-AVX512BW-LABEL: narrowExtractedVectorSelect_crash:
579 ; X64-AVX512BW: # %bb.0:
580 ; X64-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
581 ; X64-AVX512BW-NEXT: vptestmq %zmm0, %zmm0, %k0
582 ; X64-AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k1
583 ; X64-AVX512BW-NEXT: kunpckbw %k0, %k1, %k1
584 ; X64-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm1 {%k1} {z}
585 ; X64-AVX512BW-NEXT: vpmovzxwq {{.*#+}} zmm0 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
586 ; X64-AVX512BW-NEXT: vextracti128 $1, %ymm1, %xmm1
587 ; X64-AVX512BW-NEXT: vpmovzxwq {{.*#+}} zmm1 = xmm1[0],zero,zero,zero,xmm1[1],zero,zero,zero,xmm1[2],zero,zero,zero,xmm1[3],zero,zero,zero,xmm1[4],zero,zero,zero,xmm1[5],zero,zero,zero,xmm1[6],zero,zero,zero,xmm1[7],zero,zero,zero
588 ; X64-AVX512BW-NEXT: retq
589 %tmp = icmp ne <16 x i64> %arg, zeroinitializer
590 %tmp2 = select <16 x i1> %tmp, <16 x i16> %arg1, <16 x i16> zeroinitializer
591 %tmp3 = zext <16 x i16> %tmp2 to <16 x i64>