1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE,SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=SSE,SSE42
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512vl | FileCheck %s --check-prefixes=AVX512,AVX512F
7 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512vl,+avx512dq,+avx512bw | FileCheck %s --check-prefixes=AVX512,AVX512DQBW
11 define <4 x i32> @test1(<4 x i1> %cond, <4 x i32> %x) {
14 ; SSE-NEXT: pslld $31, %xmm0
15 ; SSE-NEXT: psrad $31, %xmm0
16 ; SSE-NEXT: pandn %xmm1, %xmm0
21 ; AVX-NEXT: vpslld $31, %xmm0, %xmm0
22 ; AVX-NEXT: vpsrad $31, %xmm0, %xmm0
23 ; AVX-NEXT: vpandn %xmm1, %xmm0, %xmm0
26 ; AVX512F-LABEL: test1:
28 ; AVX512F-NEXT: vpslld $31, %xmm0, %xmm0
29 ; AVX512F-NEXT: vptestnmd %xmm0, %xmm0, %k1
30 ; AVX512F-NEXT: vmovdqa32 %xmm1, %xmm0 {%k1} {z}
33 ; AVX512DQBW-LABEL: test1:
34 ; AVX512DQBW: # %bb.0:
35 ; AVX512DQBW-NEXT: vpslld $31, %xmm0, %xmm0
36 ; AVX512DQBW-NEXT: vpmovd2m %xmm0, %k0
37 ; AVX512DQBW-NEXT: knotw %k0, %k1
38 ; AVX512DQBW-NEXT: vmovdqa32 %xmm1, %xmm0 {%k1} {z}
39 ; AVX512DQBW-NEXT: retq
40 %r = select <4 x i1> %cond, <4 x i32> zeroinitializer, <4 x i32> %x
44 define <4 x i32> @test2(<4 x float> %a, <4 x float> %b, <4 x i32> %x) {
47 ; SSE-NEXT: cmpneqps %xmm1, %xmm0
48 ; SSE-NEXT: andps %xmm2, %xmm0
53 ; AVX-NEXT: vcmpneqps %xmm1, %xmm0, %xmm0
54 ; AVX-NEXT: vandps %xmm2, %xmm0, %xmm0
57 ; AVX512-LABEL: test2:
59 ; AVX512-NEXT: vcmpneqps %xmm1, %xmm0, %k1
60 ; AVX512-NEXT: vmovdqa32 %xmm2, %xmm0 {%k1} {z}
62 %cond = fcmp oeq <4 x float> %a, %b
63 %r = select <4 x i1> %cond, <4 x i32> zeroinitializer, <4 x i32> %x
67 define float @fsel_zero_false_val(float %a, float %b, float %x) {
68 ; SSE-LABEL: fsel_zero_false_val:
70 ; SSE-NEXT: cmpeqss %xmm1, %xmm0
71 ; SSE-NEXT: andps %xmm2, %xmm0
74 ; AVX-LABEL: fsel_zero_false_val:
76 ; AVX-NEXT: vcmpeqss %xmm1, %xmm0, %xmm0
77 ; AVX-NEXT: vandps %xmm2, %xmm0, %xmm0
80 ; AVX512-LABEL: fsel_zero_false_val:
82 ; AVX512-NEXT: vcmpeqss %xmm1, %xmm0, %k1
83 ; AVX512-NEXT: vmovss %xmm2, %xmm2, %xmm0 {%k1} {z}
85 %cond = fcmp oeq float %a, %b
86 %r = select i1 %cond, float %x, float 0.0
90 define float @fsel_zero_true_val(float %a, float %b, float %x) {
91 ; SSE-LABEL: fsel_zero_true_val:
93 ; SSE-NEXT: cmpeqss %xmm1, %xmm0
94 ; SSE-NEXT: andnps %xmm2, %xmm0
97 ; AVX-LABEL: fsel_zero_true_val:
99 ; AVX-NEXT: vcmpeqss %xmm1, %xmm0, %xmm0
100 ; AVX-NEXT: vandnps %xmm2, %xmm0, %xmm0
103 ; AVX512-LABEL: fsel_zero_true_val:
105 ; AVX512-NEXT: vcmpeqss %xmm1, %xmm0, %k1
106 ; AVX512-NEXT: vxorps %xmm0, %xmm0, %xmm0
107 ; AVX512-NEXT: vmovss %xmm0, %xmm2, %xmm2 {%k1}
108 ; AVX512-NEXT: vmovaps %xmm2, %xmm0
110 %cond = fcmp oeq float %a, %b
111 %r = select i1 %cond, float 0.0, float %x
115 define double @fsel_nonzero_false_val(double %x, double %y, double %z) {
116 ; SSE-LABEL: fsel_nonzero_false_val:
118 ; SSE-NEXT: cmpeqsd %xmm1, %xmm0
119 ; SSE-NEXT: andpd %xmm0, %xmm2
120 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
121 ; SSE-NEXT: andnpd %xmm1, %xmm0
122 ; SSE-NEXT: orpd %xmm2, %xmm0
125 ; AVX-LABEL: fsel_nonzero_false_val:
127 ; AVX-NEXT: vcmpeqsd %xmm1, %xmm0, %xmm0
128 ; AVX-NEXT: vmovapd {{.*#+}} xmm1 = [4.2E+1,4.2E+1]
129 ; AVX-NEXT: vblendvpd %xmm0, %xmm2, %xmm1, %xmm0
132 ; AVX512-LABEL: fsel_nonzero_false_val:
134 ; AVX512-NEXT: vcmpeqsd %xmm1, %xmm0, %k1
135 ; AVX512-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
136 ; AVX512-NEXT: vmovsd %xmm2, %xmm0, %xmm0 {%k1}
138 %cond = fcmp oeq double %x, %y
139 %r = select i1 %cond, double %z, double 42.0
143 define double @fsel_nonzero_true_val(double %x, double %y, double %z) {
144 ; SSE-LABEL: fsel_nonzero_true_val:
146 ; SSE-NEXT: cmpeqsd %xmm1, %xmm0
147 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
148 ; SSE-NEXT: andpd %xmm0, %xmm1
149 ; SSE-NEXT: andnpd %xmm2, %xmm0
150 ; SSE-NEXT: orpd %xmm1, %xmm0
153 ; AVX-LABEL: fsel_nonzero_true_val:
155 ; AVX-NEXT: vcmpeqsd %xmm1, %xmm0, %xmm0
156 ; AVX-NEXT: vblendvpd %xmm0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm0
159 ; AVX512-LABEL: fsel_nonzero_true_val:
161 ; AVX512-NEXT: vcmpeqsd %xmm1, %xmm0, %k1
162 ; AVX512-NEXT: vmovsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2 {%k1}
163 ; AVX512-NEXT: vmovapd %xmm2, %xmm0
165 %cond = fcmp oeq double %x, %y
166 %r = select i1 %cond, double 42.0, double %z
170 define double @fsel_nonzero_constants(double %x, double %y) {
171 ; SSE-LABEL: fsel_nonzero_constants:
173 ; SSE-NEXT: cmpeqsd %xmm1, %xmm0
174 ; SSE-NEXT: movq %xmm0, %rax
175 ; SSE-NEXT: andl $1, %eax
176 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
179 ; AVX-LABEL: fsel_nonzero_constants:
181 ; AVX-NEXT: vcmpeqsd %xmm1, %xmm0, %xmm0
182 ; AVX-NEXT: vmovapd {{.*#+}} xmm1 = [4.2E+1,4.2E+1]
183 ; AVX-NEXT: vblendvpd %xmm0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0
186 ; AVX512-LABEL: fsel_nonzero_constants:
188 ; AVX512-NEXT: vcmpeqsd %xmm1, %xmm0, %k1
189 ; AVX512-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
190 ; AVX512-NEXT: vmovsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 {%k1}
192 %cond = fcmp oeq double %x, %y
193 %r = select i1 %cond, double 12.0, double 42.0
197 define <2 x double> @vsel_nonzero_constants(<2 x double> %x, <2 x double> %y) {
198 ; SSE2-LABEL: vsel_nonzero_constants:
200 ; SSE2-NEXT: cmplepd %xmm0, %xmm1
201 ; SSE2-NEXT: movsd {{.*#+}} xmm2 = mem[0],zero
202 ; SSE2-NEXT: movapd %xmm1, %xmm0
203 ; SSE2-NEXT: andnpd %xmm2, %xmm0
204 ; SSE2-NEXT: andpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
205 ; SSE2-NEXT: orpd %xmm1, %xmm0
208 ; SSE42-LABEL: vsel_nonzero_constants:
210 ; SSE42-NEXT: cmplepd %xmm0, %xmm1
211 ; SSE42-NEXT: movsd {{.*#+}} xmm2 = mem[0],zero
212 ; SSE42-NEXT: movapd %xmm1, %xmm0
213 ; SSE42-NEXT: blendvpd %xmm0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2
214 ; SSE42-NEXT: movapd %xmm2, %xmm0
217 ; AVX-LABEL: vsel_nonzero_constants:
219 ; AVX-NEXT: vcmplepd %xmm0, %xmm1, %xmm0
220 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
221 ; AVX-NEXT: vblendvpd %xmm0, {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm0
224 ; AVX512-LABEL: vsel_nonzero_constants:
226 ; AVX512-NEXT: vcmplepd %xmm0, %xmm1, %k1
227 ; AVX512-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
228 ; AVX512-NEXT: vmovapd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0 {%k1}
230 %cond = fcmp oge <2 x double> %x, %y
231 %r = select <2 x i1> %cond, <2 x double> <double 12.0, double -1.0>, <2 x double> <double 42.0, double 0.0>
235 define <16 x i8> @signbit_mask_v16i8(<16 x i8> %a, <16 x i8> %b) {
236 ; SSE-LABEL: signbit_mask_v16i8:
238 ; SSE-NEXT: pxor %xmm2, %xmm2
239 ; SSE-NEXT: pcmpgtb %xmm0, %xmm2
240 ; SSE-NEXT: pand %xmm1, %xmm2
241 ; SSE-NEXT: movdqa %xmm2, %xmm0
244 ; AVX-LABEL: signbit_mask_v16i8:
246 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
247 ; AVX-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
248 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
251 ; AVX512-LABEL: signbit_mask_v16i8:
253 ; AVX512-NEXT: vpxor %xmm2, %xmm2, %xmm2
254 ; AVX512-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
255 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
257 %cond = icmp slt <16 x i8> %a, zeroinitializer
258 %r = select <16 x i1> %cond, <16 x i8> %b, <16 x i8> zeroinitializer
262 define <8 x i16> @signbit_mask_v8i16(<8 x i16> %a, <8 x i16> %b) {
263 ; SSE-LABEL: signbit_mask_v8i16:
265 ; SSE-NEXT: psraw $15, %xmm0
266 ; SSE-NEXT: pand %xmm1, %xmm0
269 ; AVX-LABEL: signbit_mask_v8i16:
271 ; AVX-NEXT: vpsraw $15, %xmm0, %xmm0
272 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
275 ; AVX512-LABEL: signbit_mask_v8i16:
277 ; AVX512-NEXT: vpsraw $15, %xmm0, %xmm0
278 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
280 %cond = icmp slt <8 x i16> %a, zeroinitializer
281 %r = select <8 x i1> %cond, <8 x i16> %b, <8 x i16> zeroinitializer
285 define <4 x i32> @signbit_mask_v4i32(<4 x i32> %a, <4 x i32> %b) {
286 ; SSE-LABEL: signbit_mask_v4i32:
288 ; SSE-NEXT: psrad $31, %xmm0
289 ; SSE-NEXT: pand %xmm1, %xmm0
292 ; AVX-LABEL: signbit_mask_v4i32:
294 ; AVX-NEXT: vpsrad $31, %xmm0, %xmm0
295 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
298 ; AVX512-LABEL: signbit_mask_v4i32:
300 ; AVX512-NEXT: vpsrad $31, %xmm0, %xmm0
301 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
303 %cond = icmp slt <4 x i32> %a, zeroinitializer
304 %r = select <4 x i1> %cond, <4 x i32> %b, <4 x i32> zeroinitializer
308 define <2 x i64> @signbit_mask_v2i64(<2 x i64> %a, <2 x i64> %b) {
309 ; SSE2-LABEL: signbit_mask_v2i64:
311 ; SSE2-NEXT: psrad $31, %xmm0
312 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
313 ; SSE2-NEXT: pand %xmm1, %xmm0
316 ; SSE42-LABEL: signbit_mask_v2i64:
318 ; SSE42-NEXT: pxor %xmm2, %xmm2
319 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm2
320 ; SSE42-NEXT: pand %xmm1, %xmm2
321 ; SSE42-NEXT: movdqa %xmm2, %xmm0
324 ; AVX-LABEL: signbit_mask_v2i64:
326 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
327 ; AVX-NEXT: vpcmpgtq %xmm0, %xmm2, %xmm0
328 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
331 ; AVX512-LABEL: signbit_mask_v2i64:
333 ; AVX512-NEXT: vpsraq $63, %xmm0, %xmm0
334 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
336 %cond = icmp slt <2 x i64> %a, zeroinitializer
337 %r = select <2 x i1> %cond, <2 x i64> %b, <2 x i64> zeroinitializer
341 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
343 define <2 x i64> @signbit_mask_swap_v2i64(<2 x i64> %a, <2 x i64> %b) {
344 ; SSE2-LABEL: signbit_mask_swap_v2i64:
346 ; SSE2-NEXT: psrad $31, %xmm0
347 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
348 ; SSE2-NEXT: pand %xmm1, %xmm0
351 ; SSE42-LABEL: signbit_mask_swap_v2i64:
353 ; SSE42-NEXT: pxor %xmm2, %xmm2
354 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm2
355 ; SSE42-NEXT: pand %xmm1, %xmm2
356 ; SSE42-NEXT: movdqa %xmm2, %xmm0
359 ; AVX-LABEL: signbit_mask_swap_v2i64:
361 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
362 ; AVX-NEXT: vpcmpgtq %xmm0, %xmm2, %xmm0
363 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
366 ; AVX512-LABEL: signbit_mask_swap_v2i64:
368 ; AVX512-NEXT: vpsraq $63, %xmm0, %xmm0
369 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
371 %cond = icmp sgt <2 x i64> %a, <i64 -1, i64 -1>
372 %r = select <2 x i1> %cond, <2 x i64> zeroinitializer, <2 x i64> %b
376 define <32 x i8> @signbit_mask_v32i8(<32 x i8> %a, <32 x i8> %b) {
377 ; SSE-LABEL: signbit_mask_v32i8:
379 ; SSE-NEXT: pxor %xmm4, %xmm4
380 ; SSE-NEXT: pxor %xmm5, %xmm5
381 ; SSE-NEXT: pcmpgtb %xmm0, %xmm5
382 ; SSE-NEXT: pand %xmm2, %xmm5
383 ; SSE-NEXT: pcmpgtb %xmm1, %xmm4
384 ; SSE-NEXT: pand %xmm3, %xmm4
385 ; SSE-NEXT: movdqa %xmm5, %xmm0
386 ; SSE-NEXT: movdqa %xmm4, %xmm1
389 ; AVX1-LABEL: signbit_mask_v32i8:
391 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
392 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
393 ; AVX1-NEXT: vpcmpgtb %xmm2, %xmm3, %xmm2
394 ; AVX1-NEXT: vpcmpgtb %xmm0, %xmm3, %xmm0
395 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
396 ; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
399 ; AVX2-LABEL: signbit_mask_v32i8:
401 ; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
402 ; AVX2-NEXT: vpcmpgtb %ymm0, %ymm2, %ymm0
403 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
406 ; AVX512-LABEL: signbit_mask_v32i8:
408 ; AVX512-NEXT: vpxor %xmm2, %xmm2, %xmm2
409 ; AVX512-NEXT: vpcmpgtb %ymm0, %ymm2, %ymm0
410 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
412 %cond = icmp slt <32 x i8> %a, zeroinitializer
413 %r = select <32 x i1> %cond, <32 x i8> %b, <32 x i8> zeroinitializer
417 define <16 x i16> @signbit_mask_v16i16(<16 x i16> %a, <16 x i16> %b) {
418 ; SSE-LABEL: signbit_mask_v16i16:
420 ; SSE-NEXT: psraw $15, %xmm0
421 ; SSE-NEXT: pand %xmm2, %xmm0
422 ; SSE-NEXT: psraw $15, %xmm1
423 ; SSE-NEXT: pand %xmm3, %xmm1
426 ; AVX1-LABEL: signbit_mask_v16i16:
428 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm2
429 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
430 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0
431 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
432 ; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
435 ; AVX2-LABEL: signbit_mask_v16i16:
437 ; AVX2-NEXT: vpsraw $15, %ymm0, %ymm0
438 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
441 ; AVX512-LABEL: signbit_mask_v16i16:
443 ; AVX512-NEXT: vpsraw $15, %ymm0, %ymm0
444 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
446 %cond = icmp slt <16 x i16> %a, zeroinitializer
447 %r = select <16 x i1> %cond, <16 x i16> %b, <16 x i16> zeroinitializer
451 define <8 x i32> @signbit_mask_v8i32(<8 x i32> %a, <8 x i32> %b) {
452 ; SSE-LABEL: signbit_mask_v8i32:
454 ; SSE-NEXT: psrad $31, %xmm0
455 ; SSE-NEXT: pand %xmm2, %xmm0
456 ; SSE-NEXT: psrad $31, %xmm1
457 ; SSE-NEXT: pand %xmm3, %xmm1
460 ; AVX1-LABEL: signbit_mask_v8i32:
462 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm2
463 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
464 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm0
465 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
466 ; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
469 ; AVX2-LABEL: signbit_mask_v8i32:
471 ; AVX2-NEXT: vpsrad $31, %ymm0, %ymm0
472 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
475 ; AVX512-LABEL: signbit_mask_v8i32:
477 ; AVX512-NEXT: vpsrad $31, %ymm0, %ymm0
478 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
480 %cond = icmp slt <8 x i32> %a, zeroinitializer
481 %r = select <8 x i1> %cond, <8 x i32> %b, <8 x i32> zeroinitializer
485 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
487 define <8 x i32> @signbit_mask_swap_v8i32(<8 x i32> %a, <8 x i32> %b) {
488 ; SSE-LABEL: signbit_mask_swap_v8i32:
490 ; SSE-NEXT: psrad $31, %xmm0
491 ; SSE-NEXT: pand %xmm2, %xmm0
492 ; SSE-NEXT: psrad $31, %xmm1
493 ; SSE-NEXT: pand %xmm3, %xmm1
496 ; AVX1-LABEL: signbit_mask_swap_v8i32:
498 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm2
499 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
500 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm0
501 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
502 ; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
505 ; AVX2-LABEL: signbit_mask_swap_v8i32:
507 ; AVX2-NEXT: vpsrad $31, %ymm0, %ymm0
508 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
511 ; AVX512-LABEL: signbit_mask_swap_v8i32:
513 ; AVX512-NEXT: vpsrad $31, %ymm0, %ymm0
514 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
516 %cond = icmp sgt <8 x i32> %a, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
517 %r = select <8 x i1> %cond, <8 x i32> zeroinitializer, <8 x i32> %b
521 define <4 x i64> @signbit_mask_v4i64(<4 x i64> %a, <4 x i64> %b) {
522 ; SSE2-LABEL: signbit_mask_v4i64:
524 ; SSE2-NEXT: psrad $31, %xmm0
525 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
526 ; SSE2-NEXT: pand %xmm2, %xmm0
527 ; SSE2-NEXT: psrad $31, %xmm1
528 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
529 ; SSE2-NEXT: pand %xmm3, %xmm1
532 ; SSE42-LABEL: signbit_mask_v4i64:
534 ; SSE42-NEXT: pxor %xmm4, %xmm4
535 ; SSE42-NEXT: pxor %xmm5, %xmm5
536 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm5
537 ; SSE42-NEXT: pand %xmm2, %xmm5
538 ; SSE42-NEXT: pcmpgtq %xmm1, %xmm4
539 ; SSE42-NEXT: pand %xmm3, %xmm4
540 ; SSE42-NEXT: movdqa %xmm5, %xmm0
541 ; SSE42-NEXT: movdqa %xmm4, %xmm1
544 ; AVX1-LABEL: signbit_mask_v4i64:
546 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
547 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
548 ; AVX1-NEXT: vpcmpgtq %xmm2, %xmm3, %xmm2
549 ; AVX1-NEXT: vpcmpgtq %xmm0, %xmm3, %xmm0
550 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
551 ; AVX1-NEXT: vandps %ymm1, %ymm0, %ymm0
554 ; AVX2-LABEL: signbit_mask_v4i64:
556 ; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
557 ; AVX2-NEXT: vpcmpgtq %ymm0, %ymm2, %ymm0
558 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
561 ; AVX512-LABEL: signbit_mask_v4i64:
563 ; AVX512-NEXT: vpsraq $63, %ymm0, %ymm0
564 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
566 %cond = icmp slt <4 x i64> %a, zeroinitializer
567 %r = select <4 x i1> %cond, <4 x i64> %b, <4 x i64> zeroinitializer
571 define <16 x i8> @signbit_setmask_v16i8(<16 x i8> %a, <16 x i8> %b) {
572 ; SSE-LABEL: signbit_setmask_v16i8:
574 ; SSE-NEXT: pxor %xmm2, %xmm2
575 ; SSE-NEXT: pcmpgtb %xmm0, %xmm2
576 ; SSE-NEXT: por %xmm1, %xmm2
577 ; SSE-NEXT: movdqa %xmm2, %xmm0
580 ; AVX-LABEL: signbit_setmask_v16i8:
582 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
583 ; AVX-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
584 ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
587 ; AVX512-LABEL: signbit_setmask_v16i8:
589 ; AVX512-NEXT: vpxor %xmm2, %xmm2, %xmm2
590 ; AVX512-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
591 ; AVX512-NEXT: vpor %xmm1, %xmm0, %xmm0
593 %cond = icmp slt <16 x i8> %a, zeroinitializer
594 %r = select <16 x i1> %cond, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8> %b
598 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
600 define <16 x i8> @signbit_setmask_swap_v16i8(<16 x i8> %a, <16 x i8> %b) {
601 ; SSE-LABEL: signbit_setmask_swap_v16i8:
603 ; SSE-NEXT: pxor %xmm2, %xmm2
604 ; SSE-NEXT: pcmpgtb %xmm0, %xmm2
605 ; SSE-NEXT: por %xmm1, %xmm2
606 ; SSE-NEXT: movdqa %xmm2, %xmm0
609 ; AVX-LABEL: signbit_setmask_swap_v16i8:
611 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
612 ; AVX-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
613 ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
616 ; AVX512-LABEL: signbit_setmask_swap_v16i8:
618 ; AVX512-NEXT: vpxor %xmm2, %xmm2, %xmm2
619 ; AVX512-NEXT: vpcmpgtb %xmm0, %xmm2, %xmm0
620 ; AVX512-NEXT: vpor %xmm1, %xmm0, %xmm0
622 %cond = icmp sgt <16 x i8> %a, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
623 %r = select <16 x i1> %cond, <16 x i8> %b, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
627 define <8 x i16> @signbit_setmask_v8i16(<8 x i16> %a, <8 x i16> %b) {
628 ; SSE-LABEL: signbit_setmask_v8i16:
630 ; SSE-NEXT: psraw $15, %xmm0
631 ; SSE-NEXT: por %xmm1, %xmm0
634 ; AVX-LABEL: signbit_setmask_v8i16:
636 ; AVX-NEXT: vpsraw $15, %xmm0, %xmm0
637 ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
640 ; AVX512-LABEL: signbit_setmask_v8i16:
642 ; AVX512-NEXT: vpsraw $15, %xmm0, %xmm0
643 ; AVX512-NEXT: vpor %xmm1, %xmm0, %xmm0
645 %cond = icmp slt <8 x i16> %a, zeroinitializer
646 %r = select <8 x i1> %cond, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> %b
650 define <4 x i32> @signbit_setmask_v4i32(<4 x i32> %a, <4 x i32> %b) {
651 ; SSE-LABEL: signbit_setmask_v4i32:
653 ; SSE-NEXT: psrad $31, %xmm0
654 ; SSE-NEXT: por %xmm1, %xmm0
657 ; AVX-LABEL: signbit_setmask_v4i32:
659 ; AVX-NEXT: vpsrad $31, %xmm0, %xmm0
660 ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
663 ; AVX512-LABEL: signbit_setmask_v4i32:
665 ; AVX512-NEXT: vpsrad $31, %xmm0, %xmm0
666 ; AVX512-NEXT: vpor %xmm1, %xmm0, %xmm0
668 %cond = icmp slt <4 x i32> %a, zeroinitializer
669 %r = select <4 x i1> %cond, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %b
673 define <2 x i64> @signbit_setmask_v2i64(<2 x i64> %a, <2 x i64> %b) {
674 ; SSE2-LABEL: signbit_setmask_v2i64:
676 ; SSE2-NEXT: psrad $31, %xmm0
677 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
678 ; SSE2-NEXT: por %xmm1, %xmm0
681 ; SSE42-LABEL: signbit_setmask_v2i64:
683 ; SSE42-NEXT: pxor %xmm2, %xmm2
684 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm2
685 ; SSE42-NEXT: por %xmm1, %xmm2
686 ; SSE42-NEXT: movdqa %xmm2, %xmm0
689 ; AVX-LABEL: signbit_setmask_v2i64:
691 ; AVX-NEXT: vpxor %xmm2, %xmm2, %xmm2
692 ; AVX-NEXT: vpcmpgtq %xmm0, %xmm2, %xmm0
693 ; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
696 ; AVX512-LABEL: signbit_setmask_v2i64:
698 ; AVX512-NEXT: vpsraq $63, %xmm0, %xmm0
699 ; AVX512-NEXT: vpor %xmm1, %xmm0, %xmm0
701 %cond = icmp slt <2 x i64> %a, zeroinitializer
702 %r = select <2 x i1> %cond, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %b
706 define <32 x i8> @signbit_setmask_v32i8(<32 x i8> %a, <32 x i8> %b) {
707 ; SSE-LABEL: signbit_setmask_v32i8:
709 ; SSE-NEXT: pxor %xmm4, %xmm4
710 ; SSE-NEXT: pxor %xmm5, %xmm5
711 ; SSE-NEXT: pcmpgtb %xmm0, %xmm5
712 ; SSE-NEXT: por %xmm2, %xmm5
713 ; SSE-NEXT: pcmpgtb %xmm1, %xmm4
714 ; SSE-NEXT: por %xmm3, %xmm4
715 ; SSE-NEXT: movdqa %xmm5, %xmm0
716 ; SSE-NEXT: movdqa %xmm4, %xmm1
719 ; AVX1-LABEL: signbit_setmask_v32i8:
721 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
722 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
723 ; AVX1-NEXT: vpcmpgtb %xmm2, %xmm3, %xmm2
724 ; AVX1-NEXT: vpcmpgtb %xmm0, %xmm3, %xmm0
725 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
726 ; AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
729 ; AVX2-LABEL: signbit_setmask_v32i8:
731 ; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
732 ; AVX2-NEXT: vpcmpgtb %ymm0, %ymm2, %ymm0
733 ; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
736 ; AVX512-LABEL: signbit_setmask_v32i8:
738 ; AVX512-NEXT: vpxor %xmm2, %xmm2, %xmm2
739 ; AVX512-NEXT: vpcmpgtb %ymm0, %ymm2, %ymm0
740 ; AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
742 %cond = icmp slt <32 x i8> %a, zeroinitializer
743 %r = select <32 x i1> %cond, <32 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <32 x i8> %b
747 define <16 x i16> @signbit_setmask_v16i16(<16 x i16> %a, <16 x i16> %b) {
748 ; SSE-LABEL: signbit_setmask_v16i16:
750 ; SSE-NEXT: psraw $15, %xmm0
751 ; SSE-NEXT: por %xmm2, %xmm0
752 ; SSE-NEXT: psraw $15, %xmm1
753 ; SSE-NEXT: por %xmm3, %xmm1
756 ; AVX1-LABEL: signbit_setmask_v16i16:
758 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm2
759 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
760 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0
761 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
762 ; AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
765 ; AVX2-LABEL: signbit_setmask_v16i16:
767 ; AVX2-NEXT: vpsraw $15, %ymm0, %ymm0
768 ; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
771 ; AVX512-LABEL: signbit_setmask_v16i16:
773 ; AVX512-NEXT: vpsraw $15, %ymm0, %ymm0
774 ; AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
776 %cond = icmp slt <16 x i16> %a, zeroinitializer
777 %r = select <16 x i1> %cond, <16 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <16 x i16> %b
781 define <8 x i32> @signbit_setmask_v8i32(<8 x i32> %a, <8 x i32> %b) {
782 ; SSE-LABEL: signbit_setmask_v8i32:
784 ; SSE-NEXT: psrad $31, %xmm0
785 ; SSE-NEXT: por %xmm2, %xmm0
786 ; SSE-NEXT: psrad $31, %xmm1
787 ; SSE-NEXT: por %xmm3, %xmm1
790 ; AVX1-LABEL: signbit_setmask_v8i32:
792 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm2
793 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
794 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm0
795 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
796 ; AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
799 ; AVX2-LABEL: signbit_setmask_v8i32:
801 ; AVX2-NEXT: vpsrad $31, %ymm0, %ymm0
802 ; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
805 ; AVX512-LABEL: signbit_setmask_v8i32:
807 ; AVX512-NEXT: vpsrad $31, %ymm0, %ymm0
808 ; AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
810 %cond = icmp slt <8 x i32> %a, zeroinitializer
811 %r = select <8 x i1> %cond, <8 x i32> <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>, <8 x i32> %b
815 define <4 x i64> @signbit_setmask_v4i64(<4 x i64> %a, <4 x i64> %b) {
816 ; SSE2-LABEL: signbit_setmask_v4i64:
818 ; SSE2-NEXT: psrad $31, %xmm0
819 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
820 ; SSE2-NEXT: por %xmm2, %xmm0
821 ; SSE2-NEXT: psrad $31, %xmm1
822 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
823 ; SSE2-NEXT: por %xmm3, %xmm1
826 ; SSE42-LABEL: signbit_setmask_v4i64:
828 ; SSE42-NEXT: pxor %xmm4, %xmm4
829 ; SSE42-NEXT: pxor %xmm5, %xmm5
830 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm5
831 ; SSE42-NEXT: por %xmm2, %xmm5
832 ; SSE42-NEXT: pcmpgtq %xmm1, %xmm4
833 ; SSE42-NEXT: por %xmm3, %xmm4
834 ; SSE42-NEXT: movdqa %xmm5, %xmm0
835 ; SSE42-NEXT: movdqa %xmm4, %xmm1
838 ; AVX1-LABEL: signbit_setmask_v4i64:
840 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
841 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
842 ; AVX1-NEXT: vpcmpgtq %xmm2, %xmm3, %xmm2
843 ; AVX1-NEXT: vpcmpgtq %xmm0, %xmm3, %xmm0
844 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
845 ; AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
848 ; AVX2-LABEL: signbit_setmask_v4i64:
850 ; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
851 ; AVX2-NEXT: vpcmpgtq %ymm0, %ymm2, %ymm0
852 ; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
855 ; AVX512-LABEL: signbit_setmask_v4i64:
857 ; AVX512-NEXT: vpsraq $63, %ymm0, %ymm0
858 ; AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
860 %cond = icmp slt <4 x i64> %a, zeroinitializer
861 %r = select <4 x i1> %cond, <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>, <4 x i64> %b
865 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
867 define <4 x i64> @signbit_setmask_swap_v4i64(<4 x i64> %a, <4 x i64> %b) {
868 ; SSE2-LABEL: signbit_setmask_swap_v4i64:
870 ; SSE2-NEXT: psrad $31, %xmm0
871 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
872 ; SSE2-NEXT: por %xmm2, %xmm0
873 ; SSE2-NEXT: psrad $31, %xmm1
874 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
875 ; SSE2-NEXT: por %xmm3, %xmm1
878 ; SSE42-LABEL: signbit_setmask_swap_v4i64:
880 ; SSE42-NEXT: pxor %xmm4, %xmm4
881 ; SSE42-NEXT: pxor %xmm5, %xmm5
882 ; SSE42-NEXT: pcmpgtq %xmm0, %xmm5
883 ; SSE42-NEXT: por %xmm2, %xmm5
884 ; SSE42-NEXT: pcmpgtq %xmm1, %xmm4
885 ; SSE42-NEXT: por %xmm3, %xmm4
886 ; SSE42-NEXT: movdqa %xmm5, %xmm0
887 ; SSE42-NEXT: movdqa %xmm4, %xmm1
890 ; AVX1-LABEL: signbit_setmask_swap_v4i64:
892 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
893 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
894 ; AVX1-NEXT: vpcmpgtq %xmm2, %xmm3, %xmm2
895 ; AVX1-NEXT: vpcmpgtq %xmm0, %xmm3, %xmm0
896 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
897 ; AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
900 ; AVX2-LABEL: signbit_setmask_swap_v4i64:
902 ; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
903 ; AVX2-NEXT: vpcmpgtq %ymm0, %ymm2, %ymm0
904 ; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
907 ; AVX512-LABEL: signbit_setmask_swap_v4i64:
909 ; AVX512-NEXT: vpsraq $63, %ymm0, %ymm0
910 ; AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
912 %cond = icmp sgt <4 x i64> %a, <i64 -1, i64 -1, i64 -1, i64 -1>
913 %r = select <4 x i1> %cond, <4 x i64> %b, <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1>
917 define <16 x i8> @not_signbit_mask_v16i8(<16 x i8> %a, <16 x i8> %b) {
918 ; SSE-LABEL: not_signbit_mask_v16i8:
920 ; SSE-NEXT: pcmpeqd %xmm2, %xmm2
921 ; SSE-NEXT: pcmpgtb %xmm2, %xmm0
922 ; SSE-NEXT: pand %xmm1, %xmm0
925 ; AVX-LABEL: not_signbit_mask_v16i8:
927 ; AVX-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
928 ; AVX-NEXT: vpcmpgtb %xmm2, %xmm0, %xmm0
929 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
932 ; AVX512-LABEL: not_signbit_mask_v16i8:
934 ; AVX512-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
935 ; AVX512-NEXT: vpcmpgtb %xmm2, %xmm0, %xmm0
936 ; AVX512-NEXT: vpand %xmm1, %xmm0, %xmm0
938 %cond = icmp sgt <16 x i8> %a, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
939 %r = select <16 x i1> %cond, <16 x i8> %b, <16 x i8> zeroinitializer
943 define <8 x i16> @not_signbit_mask_v8i16(<8 x i16> %a, <8 x i16> %b) {
944 ; SSE-LABEL: not_signbit_mask_v8i16:
946 ; SSE-NEXT: psraw $15, %xmm0
947 ; SSE-NEXT: pandn %xmm1, %xmm0
950 ; AVX-LABEL: not_signbit_mask_v8i16:
952 ; AVX-NEXT: vpsraw $15, %xmm0, %xmm0
953 ; AVX-NEXT: vpandn %xmm1, %xmm0, %xmm0
956 ; AVX512-LABEL: not_signbit_mask_v8i16:
958 ; AVX512-NEXT: vpsraw $15, %xmm0, %xmm0
959 ; AVX512-NEXT: vpandn %xmm1, %xmm0, %xmm0
961 %cond = icmp sgt <8 x i16> %a, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
962 %r = select <8 x i1> %cond, <8 x i16> %b, <8 x i16> zeroinitializer
966 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
968 define <8 x i16> @not_signbit_mask_swap_v8i16(<8 x i16> %a, <8 x i16> %b) {
969 ; SSE-LABEL: not_signbit_mask_swap_v8i16:
971 ; SSE-NEXT: psraw $15, %xmm0
972 ; SSE-NEXT: pandn %xmm1, %xmm0
975 ; AVX-LABEL: not_signbit_mask_swap_v8i16:
977 ; AVX-NEXT: vpsraw $15, %xmm0, %xmm0
978 ; AVX-NEXT: vpandn %xmm1, %xmm0, %xmm0
981 ; AVX512-LABEL: not_signbit_mask_swap_v8i16:
983 ; AVX512-NEXT: vpsraw $15, %xmm0, %xmm0
984 ; AVX512-NEXT: vpandn %xmm1, %xmm0, %xmm0
986 %cond = icmp slt <8 x i16> %a, zeroinitializer
987 %r = select <8 x i1> %cond, <8 x i16> zeroinitializer, <8 x i16> %b
991 define <4 x i32> @not_signbit_mask_v4i32(<4 x i32> %a, <4 x i32> %b) {
992 ; SSE-LABEL: not_signbit_mask_v4i32:
994 ; SSE-NEXT: psrad $31, %xmm0
995 ; SSE-NEXT: pandn %xmm1, %xmm0
998 ; AVX-LABEL: not_signbit_mask_v4i32:
1000 ; AVX-NEXT: vpsrad $31, %xmm0, %xmm0
1001 ; AVX-NEXT: vpandn %xmm1, %xmm0, %xmm0
1004 ; AVX512-LABEL: not_signbit_mask_v4i32:
1006 ; AVX512-NEXT: vpsrad $31, %xmm0, %xmm0
1007 ; AVX512-NEXT: vpandn %xmm1, %xmm0, %xmm0
1009 %cond = icmp sgt <4 x i32> %a, <i32 -1, i32 -1, i32 -1, i32 -1>
1010 %r = select <4 x i1> %cond, <4 x i32> %b, <4 x i32> zeroinitializer
1014 define <2 x i64> @not_signbit_mask_v2i64(<2 x i64> %a, <2 x i64> %b) {
1015 ; SSE2-LABEL: not_signbit_mask_v2i64:
1017 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
1018 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm2
1019 ; SSE2-NEXT: pcmpgtd %xmm2, %xmm0
1020 ; SSE2-NEXT: pand %xmm1, %xmm0
1023 ; SSE42-LABEL: not_signbit_mask_v2i64:
1025 ; SSE42-NEXT: pcmpeqd %xmm2, %xmm2
1026 ; SSE42-NEXT: pcmpgtq %xmm2, %xmm0
1027 ; SSE42-NEXT: pand %xmm1, %xmm0
1030 ; AVX-LABEL: not_signbit_mask_v2i64:
1032 ; AVX-NEXT: vpcmpeqd %xmm2, %xmm2, %xmm2
1033 ; AVX-NEXT: vpcmpgtq %xmm2, %xmm0, %xmm0
1034 ; AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
1037 ; AVX512-LABEL: not_signbit_mask_v2i64:
1039 ; AVX512-NEXT: vpsraq $63, %xmm0, %xmm0
1040 ; AVX512-NEXT: vpandn %xmm1, %xmm0, %xmm0
1042 %cond = icmp sgt <2 x i64> %a, <i64 -1, i64 -1>
1043 %r = select <2 x i1> %cond, <2 x i64> %b, <2 x i64> zeroinitializer
1047 define <32 x i8> @not_signbit_mask_v32i8(<32 x i8> %a, <32 x i8> %b) {
1048 ; SSE-LABEL: not_signbit_mask_v32i8:
1050 ; SSE-NEXT: pcmpeqd %xmm4, %xmm4
1051 ; SSE-NEXT: pcmpgtb %xmm4, %xmm0
1052 ; SSE-NEXT: pand %xmm2, %xmm0
1053 ; SSE-NEXT: pcmpgtb %xmm4, %xmm1
1054 ; SSE-NEXT: pand %xmm3, %xmm1
1057 ; AVX1-LABEL: not_signbit_mask_v32i8:
1059 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
1060 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
1061 ; AVX1-NEXT: vpcmpgtb %xmm2, %xmm3, %xmm2
1062 ; AVX1-NEXT: vpcmpgtb %xmm0, %xmm3, %xmm0
1063 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
1064 ; AVX1-NEXT: vandnps %ymm1, %ymm0, %ymm0
1067 ; AVX2-LABEL: not_signbit_mask_v32i8:
1069 ; AVX2-NEXT: vpcmpeqd %ymm2, %ymm2, %ymm2
1070 ; AVX2-NEXT: vpcmpgtb %ymm2, %ymm0, %ymm0
1071 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
1074 ; AVX512-LABEL: not_signbit_mask_v32i8:
1076 ; AVX512-NEXT: vpcmpeqd %ymm2, %ymm2, %ymm2
1077 ; AVX512-NEXT: vpcmpgtb %ymm2, %ymm0, %ymm0
1078 ; AVX512-NEXT: vpand %ymm1, %ymm0, %ymm0
1080 %cond = icmp sgt <32 x i8> %a, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
1081 %r = select <32 x i1> %cond, <32 x i8> %b, <32 x i8> zeroinitializer
1085 define <16 x i16> @not_signbit_mask_v16i16(<16 x i16> %a, <16 x i16> %b) {
1086 ; SSE-LABEL: not_signbit_mask_v16i16:
1088 ; SSE-NEXT: psraw $15, %xmm0
1089 ; SSE-NEXT: pandn %xmm2, %xmm0
1090 ; SSE-NEXT: psraw $15, %xmm1
1091 ; SSE-NEXT: pandn %xmm3, %xmm1
1094 ; AVX1-LABEL: not_signbit_mask_v16i16:
1096 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm2
1097 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
1098 ; AVX1-NEXT: vpsraw $15, %xmm0, %xmm0
1099 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
1100 ; AVX1-NEXT: vandnps %ymm1, %ymm0, %ymm0
1103 ; AVX2-LABEL: not_signbit_mask_v16i16:
1105 ; AVX2-NEXT: vpsraw $15, %ymm0, %ymm0
1106 ; AVX2-NEXT: vpandn %ymm1, %ymm0, %ymm0
1109 ; AVX512-LABEL: not_signbit_mask_v16i16:
1111 ; AVX512-NEXT: vpsraw $15, %ymm0, %ymm0
1112 ; AVX512-NEXT: vpandn %ymm1, %ymm0, %ymm0
1114 %cond = icmp sgt <16 x i16> %a, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
1115 %r = select <16 x i1> %cond, <16 x i16> %b, <16 x i16> zeroinitializer
1119 define <8 x i32> @not_signbit_mask_v8i32(<8 x i32> %a, <8 x i32> %b) {
1120 ; SSE-LABEL: not_signbit_mask_v8i32:
1122 ; SSE-NEXT: psrad $31, %xmm0
1123 ; SSE-NEXT: pandn %xmm2, %xmm0
1124 ; SSE-NEXT: psrad $31, %xmm1
1125 ; SSE-NEXT: pandn %xmm3, %xmm1
1128 ; AVX1-LABEL: not_signbit_mask_v8i32:
1130 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm2
1131 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
1132 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm0
1133 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
1134 ; AVX1-NEXT: vandnps %ymm1, %ymm0, %ymm0
1137 ; AVX2-LABEL: not_signbit_mask_v8i32:
1139 ; AVX2-NEXT: vpsrad $31, %ymm0, %ymm0
1140 ; AVX2-NEXT: vpandn %ymm1, %ymm0, %ymm0
1143 ; AVX512-LABEL: not_signbit_mask_v8i32:
1145 ; AVX512-NEXT: vpsrad $31, %ymm0, %ymm0
1146 ; AVX512-NEXT: vpandn %ymm1, %ymm0, %ymm0
1148 %cond = icmp sgt <8 x i32> %a, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
1149 %r = select <8 x i1> %cond, <8 x i32> %b, <8 x i32> zeroinitializer
1153 ; Swap cmp pred and select ops. This is logically equivalent to the above test.
1155 define <8 x i32> @not_signbit_mask_swap_v8i32(<8 x i32> %a, <8 x i32> %b) {
1156 ; SSE-LABEL: not_signbit_mask_swap_v8i32:
1158 ; SSE-NEXT: psrad $31, %xmm0
1159 ; SSE-NEXT: pandn %xmm2, %xmm0
1160 ; SSE-NEXT: psrad $31, %xmm1
1161 ; SSE-NEXT: pandn %xmm3, %xmm1
1164 ; AVX1-LABEL: not_signbit_mask_swap_v8i32:
1166 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm2
1167 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0
1168 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm0
1169 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm2, %ymm0
1170 ; AVX1-NEXT: vandnps %ymm1, %ymm0, %ymm0
1173 ; AVX2-LABEL: not_signbit_mask_swap_v8i32:
1175 ; AVX2-NEXT: vpsrad $31, %ymm0, %ymm0
1176 ; AVX2-NEXT: vpandn %ymm1, %ymm0, %ymm0
1179 ; AVX512-LABEL: not_signbit_mask_swap_v8i32:
1181 ; AVX512-NEXT: vpsrad $31, %ymm0, %ymm0
1182 ; AVX512-NEXT: vpandn %ymm1, %ymm0, %ymm0
1184 %cond = icmp slt <8 x i32> %a, zeroinitializer
1185 %r = select <8 x i1> %cond, <8 x i32> zeroinitializer, <8 x i32> %b
1189 define <4 x i64> @not_signbit_mask_v4i64(<4 x i64> %a, <4 x i64> %b) {
1190 ; SSE2-LABEL: not_signbit_mask_v4i64:
1192 ; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
1193 ; SSE2-NEXT: pcmpeqd %xmm4, %xmm4
1194 ; SSE2-NEXT: pcmpgtd %xmm4, %xmm0
1195 ; SSE2-NEXT: pand %xmm2, %xmm0
1196 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
1197 ; SSE2-NEXT: pcmpgtd %xmm4, %xmm1
1198 ; SSE2-NEXT: pand %xmm3, %xmm1
1201 ; SSE42-LABEL: not_signbit_mask_v4i64:
1203 ; SSE42-NEXT: pcmpeqd %xmm4, %xmm4
1204 ; SSE42-NEXT: pcmpgtq %xmm4, %xmm0
1205 ; SSE42-NEXT: pand %xmm2, %xmm0
1206 ; SSE42-NEXT: pcmpgtq %xmm4, %xmm1
1207 ; SSE42-NEXT: pand %xmm3, %xmm1
1210 ; AVX1-LABEL: not_signbit_mask_v4i64:
1212 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
1213 ; AVX1-NEXT: vpxor %xmm3, %xmm3, %xmm3
1214 ; AVX1-NEXT: vpcmpgtq %xmm2, %xmm3, %xmm2
1215 ; AVX1-NEXT: vpcmpgtq %xmm0, %xmm3, %xmm0
1216 ; AVX1-NEXT: vinsertf128 $1, %xmm2, %ymm0, %ymm0
1217 ; AVX1-NEXT: vandnps %ymm1, %ymm0, %ymm0
1220 ; AVX2-LABEL: not_signbit_mask_v4i64:
1222 ; AVX2-NEXT: vpcmpeqd %ymm2, %ymm2, %ymm2
1223 ; AVX2-NEXT: vpcmpgtq %ymm2, %ymm0, %ymm0
1224 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
1227 ; AVX512-LABEL: not_signbit_mask_v4i64:
1229 ; AVX512-NEXT: vpsraq $63, %ymm0, %ymm0
1230 ; AVX512-NEXT: vpandn %ymm1, %ymm0, %ymm0
1232 %cond = icmp sgt <4 x i64> %a, <i64 -1, i64 -1, i64 -1, i64 -1>
1233 %r = select <4 x i1> %cond, <4 x i64> %b, <4 x i64> zeroinitializer