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: pushl %ebp
440 ; X86-AVX512F-NEXT: .cfi_def_cfa_offset 8
441 ; X86-AVX512F-NEXT: .cfi_offset %ebp, -8
442 ; X86-AVX512F-NEXT: movl %esp, %ebp
443 ; X86-AVX512F-NEXT: .cfi_def_cfa_register %ebp
444 ; X86-AVX512F-NEXT: andl $-32, %esp
445 ; X86-AVX512F-NEXT: subl $32, %esp
446 ; X86-AVX512F-NEXT: testb $1, 8(%ebp)
447 ; X86-AVX512F-NEXT: jne .LBB14_2
448 ; X86-AVX512F-NEXT: # %bb.1:
449 ; X86-AVX512F-NEXT: vmovaps 40(%ebp), %ymm1
450 ; X86-AVX512F-NEXT: vmovaps %ymm2, %ymm0
451 ; X86-AVX512F-NEXT: .LBB14_2:
452 ; X86-AVX512F-NEXT: movl %ebp, %esp
453 ; X86-AVX512F-NEXT: popl %ebp
454 ; X86-AVX512F-NEXT: .cfi_def_cfa %esp, 4
455 ; X86-AVX512F-NEXT: retl
457 ; X64-AVX512F-LABEL: pr42355_v32i16:
458 ; X64-AVX512F: # %bb.0:
459 ; X64-AVX512F-NEXT: testb $1, %dil
460 ; X64-AVX512F-NEXT: jne .LBB14_2
461 ; X64-AVX512F-NEXT: # %bb.1:
462 ; X64-AVX512F-NEXT: vmovaps %ymm2, %ymm0
463 ; X64-AVX512F-NEXT: vmovaps %ymm3, %ymm1
464 ; X64-AVX512F-NEXT: .LBB14_2:
465 ; X64-AVX512F-NEXT: retq
467 ; X86-AVX512BW-LABEL: pr42355_v32i16:
468 ; X86-AVX512BW: # %bb.0:
469 ; X86-AVX512BW-NEXT: testb $1, {{[0-9]+}}(%esp)
470 ; X86-AVX512BW-NEXT: jne .LBB14_2
471 ; X86-AVX512BW-NEXT: # %bb.1:
472 ; X86-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
473 ; X86-AVX512BW-NEXT: .LBB14_2:
474 ; X86-AVX512BW-NEXT: retl
476 ; X64-AVX512BW-LABEL: pr42355_v32i16:
477 ; X64-AVX512BW: # %bb.0:
478 ; X64-AVX512BW-NEXT: testb $1, %dil
479 ; X64-AVX512BW-NEXT: jne .LBB14_2
480 ; X64-AVX512BW-NEXT: # %bb.1:
481 ; X64-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
482 ; X64-AVX512BW-NEXT: .LBB14_2:
483 ; X64-AVX512BW-NEXT: retq
484 %a = select i1 %c, <32 x i16> %x, <32 x i16> %y
488 define <64 x i8> @pr42355_v64i8(i1 %c, <64 x i8> %x, <64 x i8> %y) {
489 ; X86-AVX512F-LABEL: pr42355_v64i8:
490 ; X86-AVX512F: # %bb.0:
491 ; X86-AVX512F-NEXT: pushl %ebp
492 ; X86-AVX512F-NEXT: .cfi_def_cfa_offset 8
493 ; X86-AVX512F-NEXT: .cfi_offset %ebp, -8
494 ; X86-AVX512F-NEXT: movl %esp, %ebp
495 ; X86-AVX512F-NEXT: .cfi_def_cfa_register %ebp
496 ; X86-AVX512F-NEXT: andl $-32, %esp
497 ; X86-AVX512F-NEXT: subl $32, %esp
498 ; X86-AVX512F-NEXT: testb $1, 8(%ebp)
499 ; X86-AVX512F-NEXT: jne .LBB15_2
500 ; X86-AVX512F-NEXT: # %bb.1:
501 ; X86-AVX512F-NEXT: vmovaps 40(%ebp), %ymm1
502 ; X86-AVX512F-NEXT: vmovaps %ymm2, %ymm0
503 ; X86-AVX512F-NEXT: .LBB15_2:
504 ; X86-AVX512F-NEXT: movl %ebp, %esp
505 ; X86-AVX512F-NEXT: popl %ebp
506 ; X86-AVX512F-NEXT: .cfi_def_cfa %esp, 4
507 ; X86-AVX512F-NEXT: retl
509 ; X64-AVX512F-LABEL: pr42355_v64i8:
510 ; X64-AVX512F: # %bb.0:
511 ; X64-AVX512F-NEXT: testb $1, %dil
512 ; X64-AVX512F-NEXT: jne .LBB15_2
513 ; X64-AVX512F-NEXT: # %bb.1:
514 ; X64-AVX512F-NEXT: vmovaps %ymm2, %ymm0
515 ; X64-AVX512F-NEXT: vmovaps %ymm3, %ymm1
516 ; X64-AVX512F-NEXT: .LBB15_2:
517 ; X64-AVX512F-NEXT: retq
519 ; X86-AVX512BW-LABEL: pr42355_v64i8:
520 ; X86-AVX512BW: # %bb.0:
521 ; X86-AVX512BW-NEXT: testb $1, {{[0-9]+}}(%esp)
522 ; X86-AVX512BW-NEXT: jne .LBB15_2
523 ; X86-AVX512BW-NEXT: # %bb.1:
524 ; X86-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
525 ; X86-AVX512BW-NEXT: .LBB15_2:
526 ; X86-AVX512BW-NEXT: retl
528 ; X64-AVX512BW-LABEL: pr42355_v64i8:
529 ; X64-AVX512BW: # %bb.0:
530 ; X64-AVX512BW-NEXT: testb $1, %dil
531 ; X64-AVX512BW-NEXT: jne .LBB15_2
532 ; X64-AVX512BW-NEXT: # %bb.1:
533 ; X64-AVX512BW-NEXT: vmovaps %zmm1, %zmm0
534 ; X64-AVX512BW-NEXT: .LBB15_2:
535 ; X64-AVX512BW-NEXT: retq
536 %a = select i1 %c, <64 x i8> %x, <64 x i8> %y
540 ; This would crash because AVX512 has legal vector select
541 ; condition values that are not 256/512-bit vectors.
543 define <16 x i64> @narrowExtractedVectorSelect_crash(<16 x i64> %arg, <16 x i16> %arg1) #0 {
544 ; X86-AVX512F-LABEL: narrowExtractedVectorSelect_crash:
545 ; X86-AVX512F: # %bb.0:
546 ; X86-AVX512F-NEXT: vptestmq %zmm0, %zmm0, %k0
547 ; X86-AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k1
548 ; X86-AVX512F-NEXT: kunpckbw %k0, %k1, %k1
549 ; X86-AVX512F-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
550 ; X86-AVX512F-NEXT: vpmovdw %zmm0, %ymm0
551 ; X86-AVX512F-NEXT: vpand %ymm2, %ymm0, %ymm1
552 ; 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
553 ; X86-AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
554 ; 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
555 ; X86-AVX512F-NEXT: retl
557 ; X64-AVX512F-LABEL: narrowExtractedVectorSelect_crash:
558 ; X64-AVX512F: # %bb.0:
559 ; X64-AVX512F-NEXT: vptestmq %zmm0, %zmm0, %k0
560 ; X64-AVX512F-NEXT: vptestmq %zmm1, %zmm1, %k1
561 ; X64-AVX512F-NEXT: kunpckbw %k0, %k1, %k1
562 ; X64-AVX512F-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
563 ; X64-AVX512F-NEXT: vpmovdw %zmm0, %ymm0
564 ; X64-AVX512F-NEXT: vpand %ymm2, %ymm0, %ymm1
565 ; 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
566 ; X64-AVX512F-NEXT: vextracti128 $1, %ymm1, %xmm1
567 ; 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
568 ; X64-AVX512F-NEXT: retq
570 ; X86-AVX512BW-LABEL: narrowExtractedVectorSelect_crash:
571 ; X86-AVX512BW: # %bb.0:
572 ; X86-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
573 ; X86-AVX512BW-NEXT: vptestmq %zmm0, %zmm0, %k0
574 ; X86-AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k1
575 ; X86-AVX512BW-NEXT: kunpckbw %k0, %k1, %k1
576 ; X86-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm1 {%k1} {z}
577 ; 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
578 ; X86-AVX512BW-NEXT: vextracti128 $1, %ymm1, %xmm1
579 ; 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
580 ; X86-AVX512BW-NEXT: retl
582 ; X64-AVX512BW-LABEL: narrowExtractedVectorSelect_crash:
583 ; X64-AVX512BW: # %bb.0:
584 ; X64-AVX512BW-NEXT: # kill: def $ymm2 killed $ymm2 def $zmm2
585 ; X64-AVX512BW-NEXT: vptestmq %zmm0, %zmm0, %k0
586 ; X64-AVX512BW-NEXT: vptestmq %zmm1, %zmm1, %k1
587 ; X64-AVX512BW-NEXT: kunpckbw %k0, %k1, %k1
588 ; X64-AVX512BW-NEXT: vmovdqu16 %zmm2, %zmm1 {%k1} {z}
589 ; 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
590 ; X64-AVX512BW-NEXT: vextracti128 $1, %ymm1, %xmm1
591 ; 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
592 ; X64-AVX512BW-NEXT: retq
593 %tmp = icmp ne <16 x i64> %arg, zeroinitializer
594 %tmp2 = select <16 x i1> %tmp, <16 x i16> %arg1, <16 x i16> zeroinitializer
595 %tmp3 = zext <16 x i16> %tmp2 to <16 x i64>