From: Simon Pilgrim Date: Mon, 3 Apr 2023 11:37:53 +0000 (+0100) Subject: [X86] Test coverage for icmp_eq(bitcast(vXi1 trunc(Y)),0) style reduction patterns X-Git-Tag: upstream/17.0.6~12876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82df745e57be2b5765b0249e6afaff0627c470bd;p=platform%2Fupstream%2Fllvm.git [X86] Test coverage for icmp_eq(bitcast(vXi1 trunc(Y)),0) style reduction patterns Add SSE41 test coverage as well --- diff --git a/llvm/test/CodeGen/X86/bitcast-vector-bool.ll b/llvm/test/CodeGen/X86/bitcast-vector-bool.ll index 5dbd766..4c87e98 100644 --- a/llvm/test/CodeGen/X86/bitcast-vector-bool.ll +++ b/llvm/test/CodeGen/X86/bitcast-vector-bool.ll @@ -1,6 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=SSE2-SSSE3 -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+ssse3 | FileCheck %s --check-prefix=SSE2-SSSE3 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE,SSE2-SSSE3 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+ssse3 | FileCheck %s --check-prefixes=SSE,SSE2-SSSE3 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefixes=SSE,SSE41 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX12,AVX1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX12,AVX2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512vl,+avx512bw | FileCheck %s --check-prefixes=AVX,AVX512 @@ -10,13 +11,13 @@ ; define i1 @bitcast_v2i64_to_v2i1(<2 x i64> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v2i64_to_v2i1: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: movmskpd %xmm0, %ecx -; SSE2-SSSE3-NEXT: movl %ecx, %eax -; SSE2-SSSE3-NEXT: shrb %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v2i64_to_v2i1: +; SSE: # %bb.0: +; SSE-NEXT: movmskpd %xmm0, %ecx +; SSE-NEXT: movl %ecx, %eax +; SSE-NEXT: shrb %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: retq ; ; AVX12-LABEL: bitcast_v2i64_to_v2i1: ; AVX12: # %bb.0: @@ -44,16 +45,47 @@ define i1 @bitcast_v2i64_to_v2i1(<2 x i64> %a0) nounwind { ret i1 %5 } +define i1 @trunc_v2i64_cmp(<2 x i64> %a0) nounwind { +; SSE-LABEL: trunc_v2i64_cmp: +; SSE: # %bb.0: +; SSE-NEXT: psllq $63, %xmm0 +; SSE-NEXT: movmskpd %xmm0, %eax +; SSE-NEXT: testl %eax, %eax +; SSE-NEXT: sete %al +; SSE-NEXT: retq +; +; AVX12-LABEL: trunc_v2i64_cmp: +; AVX12: # %bb.0: +; AVX12-NEXT: vpsllq $63, %xmm0, %xmm0 +; AVX12-NEXT: vmovmskpd %xmm0, %eax +; AVX12-NEXT: testl %eax, %eax +; AVX12-NEXT: sete %al +; AVX12-NEXT: retq +; +; AVX512-LABEL: trunc_v2i64_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllq $63, %xmm0, %xmm0 +; AVX512-NEXT: vptestmq %xmm0, %xmm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: testb %al, %al +; AVX512-NEXT: sete %al +; AVX512-NEXT: retq + %1 = trunc <2 x i64> %a0 to <2 x i1> + %2 = bitcast <2 x i1> %1 to i2 + %3 = icmp eq i2 %2, 0 + ret i1 %3 +} + define i2 @bitcast_v4i32_to_v2i2(<4 x i32> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v4i32_to_v2i2: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: movmskps %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %ecx -; SSE2-SSSE3-NEXT: shrb $2, %cl -; SSE2-SSSE3-NEXT: andb $3, %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v4i32_to_v2i2: +; SSE: # %bb.0: +; SSE-NEXT: movmskps %xmm0, %eax +; SSE-NEXT: movl %eax, %ecx +; SSE-NEXT: shrb $2, %cl +; SSE-NEXT: andb $3, %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: retq ; ; AVX-LABEL: bitcast_v4i32_to_v2i2: ; AVX: # %bb.0: @@ -72,17 +104,48 @@ define i2 @bitcast_v4i32_to_v2i2(<4 x i32> %a0) nounwind { ret i2 %5 } +define i1 @trunc_v4i32_cmp(<4 x i32> %a0) nounwind { +; SSE-LABEL: trunc_v4i32_cmp: +; SSE: # %bb.0: +; SSE-NEXT: pslld $31, %xmm0 +; SSE-NEXT: movmskps %xmm0, %eax +; SSE-NEXT: cmpb $15, %al +; SSE-NEXT: sete %al +; SSE-NEXT: retq +; +; AVX12-LABEL: trunc_v4i32_cmp: +; AVX12: # %bb.0: +; AVX12-NEXT: vpslld $31, %xmm0, %xmm0 +; AVX12-NEXT: vmovmskps %xmm0, %eax +; AVX12-NEXT: cmpb $15, %al +; AVX12-NEXT: sete %al +; AVX12-NEXT: retq +; +; AVX512-LABEL: trunc_v4i32_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpslld $31, %xmm0, %xmm0 +; AVX512-NEXT: vptestnmd %xmm0, %xmm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: testb $15, %al +; AVX512-NEXT: sete %al +; AVX512-NEXT: retq + %1 = trunc <4 x i32> %a0 to <4 x i1> + %2 = bitcast <4 x i1> %1 to i4 + %3 = icmp eq i4 %2, -1 + ret i1 %3 +} + define i4 @bitcast_v8i16_to_v2i4(<8 x i16> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v8i16_to_v2i4: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: packsswb %xmm0, %xmm0 -; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %ecx -; SSE2-SSSE3-NEXT: shrb $4, %cl -; SSE2-SSSE3-NEXT: andb $15, %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v8i16_to_v2i4: +; SSE: # %bb.0: +; SSE-NEXT: packsswb %xmm0, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: movl %eax, %ecx +; SSE-NEXT: shrb $4, %cl +; SSE-NEXT: andb $15, %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: retq ; ; AVX12-LABEL: bitcast_v8i16_to_v2i4: ; AVX12: # %bb.0: @@ -113,6 +176,37 @@ define i4 @bitcast_v8i16_to_v2i4(<8 x i16> %a0) nounwind { ret i4 %5 } +define i1 @trunc_v8i16_cmp(<8 x i16> %a0) nounwind { +; SSE-LABEL: trunc_v8i16_cmp: +; SSE: # %bb.0: +; SSE-NEXT: psllw $15, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: testl $43690, %eax # imm = 0xAAAA +; SSE-NEXT: setne %al +; SSE-NEXT: retq +; +; AVX12-LABEL: trunc_v8i16_cmp: +; AVX12: # %bb.0: +; AVX12-NEXT: vpsllw $15, %xmm0, %xmm0 +; AVX12-NEXT: vpmovmskb %xmm0, %eax +; AVX12-NEXT: testl $43690, %eax # imm = 0xAAAA +; AVX12-NEXT: setne %al +; AVX12-NEXT: retq +; +; AVX512-LABEL: trunc_v8i16_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $15, %xmm0, %xmm0 +; AVX512-NEXT: vpmovw2m %xmm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: testb %al, %al +; AVX512-NEXT: setne %al +; AVX512-NEXT: retq + %1 = trunc <8 x i16> %a0 to <8 x i1> + %2 = bitcast <8 x i1> %1 to i8 + %3 = icmp ne i8 %2, 0 + ret i1 %3 +} + define i8 @bitcast_v16i8_to_v2i8(<16 x i8> %a0) nounwind { ; SSE2-SSSE3-LABEL: bitcast_v16i8_to_v2i8: ; SSE2-SSSE3: # %bb.0: @@ -123,6 +217,15 @@ define i8 @bitcast_v16i8_to_v2i8(<16 x i8> %a0) nounwind { ; SSE2-SSSE3-NEXT: addb -{{[0-9]+}}(%rsp), %al ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: bitcast_v16i8_to_v2i8: +; SSE41: # %bb.0: +; SSE41-NEXT: pmovmskb %xmm0, %ecx +; SSE41-NEXT: movl %ecx, %eax +; SSE41-NEXT: shrl $8, %eax +; SSE41-NEXT: addb %cl, %al +; SSE41-NEXT: # kill: def $al killed $al killed $eax +; SSE41-NEXT: retq +; ; AVX12-LABEL: bitcast_v16i8_to_v2i8: ; AVX12: # %bb.0: ; AVX12-NEXT: vpmovmskb %xmm0, %ecx @@ -149,21 +252,43 @@ define i8 @bitcast_v16i8_to_v2i8(<16 x i8> %a0) nounwind { ret i8 %5 } +define i1 @trunc_v16i8_cmp(<16 x i8> %a0) nounwind { +; SSE-LABEL: trunc_v16i8_cmp: +; SSE: # %bb.0: +; SSE-NEXT: psllw $7, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: setne %al +; SSE-NEXT: retq +; +; AVX-LABEL: trunc_v16i8_cmp: +; AVX: # %bb.0: +; AVX-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX-NEXT: vpmovmskb %xmm0, %eax +; AVX-NEXT: cmpw $-1, %ax +; AVX-NEXT: setne %al +; AVX-NEXT: retq + %1 = trunc <16 x i8> %a0 to <16 x i1> + %2 = bitcast <16 x i1> %1 to i16 + %3 = icmp ne i16 %2, -1 + ret i1 %3 +} + ; ; 256-bit vectors ; define i2 @bitcast_v4i64_to_v2i2(<4 x i64> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v4i64_to_v2i2: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: packssdw %xmm1, %xmm0 -; SSE2-SSSE3-NEXT: movmskps %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %ecx -; SSE2-SSSE3-NEXT: shrb $2, %cl -; SSE2-SSSE3-NEXT: andb $3, %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v4i64_to_v2i2: +; SSE: # %bb.0: +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: movmskps %xmm0, %eax +; SSE-NEXT: movl %eax, %ecx +; SSE-NEXT: shrb $2, %cl +; SSE-NEXT: andb $3, %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: retq ; ; AVX-LABEL: bitcast_v4i64_to_v2i2: ; AVX: # %bb.0: @@ -183,18 +308,63 @@ define i2 @bitcast_v4i64_to_v2i2(<4 x i64> %a0) nounwind { ret i2 %5 } +define i1 @trunc_v4i64_cmp(<4 x i64> %a0) nounwind { +; SSE-LABEL: trunc_v4i64_cmp: +; SSE: # %bb.0: +; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,2] +; SSE-NEXT: pslld $31, %xmm0 +; SSE-NEXT: movmskps %xmm0, %eax +; SSE-NEXT: testl %eax, %eax +; SSE-NEXT: setne %al +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_v4i64_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 +; AVX1-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,2] +; AVX1-NEXT: vpslld $31, %xmm0, %xmm0 +; AVX1-NEXT: vmovmskps %xmm0, %eax +; AVX1-NEXT: testl %eax, %eax +; AVX1-NEXT: setne %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v4i64_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsllq $63, %ymm0, %ymm0 +; AVX2-NEXT: vmovmskpd %ymm0, %eax +; AVX2-NEXT: testl %eax, %eax +; AVX2-NEXT: setne %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v4i64_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllq $63, %ymm0, %ymm0 +; AVX512-NEXT: vptestmq %ymm0, %ymm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: testb %al, %al +; AVX512-NEXT: setne %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <4 x i64> %a0 to <4 x i1> + %2 = bitcast <4 x i1> %1 to i4 + %3 = icmp ne i4 %2, 0 + ret i1 %3 +} + define i4 @bitcast_v8i32_to_v2i4(<8 x i32> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v8i32_to_v2i4: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: packssdw %xmm1, %xmm0 -; SSE2-SSSE3-NEXT: packsswb %xmm0, %xmm0 -; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %ecx -; SSE2-SSSE3-NEXT: shrb $4, %cl -; SSE2-SSSE3-NEXT: andb $15, %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v8i32_to_v2i4: +; SSE: # %bb.0: +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: packsswb %xmm0, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: movl %eax, %ecx +; SSE-NEXT: shrb $4, %cl +; SSE-NEXT: andb $15, %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: retq ; ; AVX-LABEL: bitcast_v8i32_to_v2i4: ; AVX: # %bb.0: @@ -214,6 +384,55 @@ define i4 @bitcast_v8i32_to_v2i4(<8 x i32> %a0) nounwind { ret i4 %5 } +define i1 @trunc_v8i132_cmp(<8 x i32> %a0) nounwind { +; SSE41-LABEL: trunc_v8i132_cmp: +; SSE41: # %bb.0: +; SSE41-NEXT: pxor %xmm2, %xmm2 +; SSE41-NEXT: pblendw {{.*#+}} xmm1 = xmm1[0],xmm2[1],xmm1[2],xmm2[3],xmm1[4],xmm2[5],xmm1[6],xmm2[7] +; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0],xmm2[1],xmm0[2],xmm2[3],xmm0[4],xmm2[5],xmm0[6],xmm2[7] +; SSE41-NEXT: packusdw %xmm1, %xmm0 +; SSE41-NEXT: psllw $15, %xmm0 +; SSE41-NEXT: packsswb %xmm0, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %eax +; SSE41-NEXT: cmpb $-1, %al +; SSE41-NEXT: setne %al +; SSE41-NEXT: retq +; +; AVX1-LABEL: trunc_v8i132_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 +; AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpslld $31, %xmm0, %xmm0 +; AVX1-NEXT: vmovmskps %xmm0, %eax +; AVX1-NEXT: cmpl $15, %eax +; AVX1-NEXT: setne %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v8i132_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpslld $31, %ymm0, %ymm0 +; AVX2-NEXT: vmovmskps %ymm0, %eax +; AVX2-NEXT: cmpb $-1, %al +; AVX2-NEXT: setne %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v8i132_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpslld $31, %ymm0, %ymm0 +; AVX512-NEXT: vptestmd %ymm0, %ymm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: cmpb $-1, %al +; AVX512-NEXT: setne %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <8 x i32> %a0 to <8 x i1> + %2 = bitcast <8 x i1> %1 to i8 + %3 = icmp ne i8 %2, -1 + ret i1 %3 +} + define i8 @bitcast_v16i16_to_v2i8(<16 x i16> %a0) nounwind { ; SSE2-SSSE3-LABEL: bitcast_v16i16_to_v2i8: ; SSE2-SSSE3: # %bb.0: @@ -225,6 +444,16 @@ define i8 @bitcast_v16i16_to_v2i8(<16 x i16> %a0) nounwind { ; SSE2-SSSE3-NEXT: addb -{{[0-9]+}}(%rsp), %al ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: bitcast_v16i16_to_v2i8: +; SSE41: # %bb.0: +; SSE41-NEXT: packsswb %xmm1, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %ecx +; SSE41-NEXT: movl %ecx, %eax +; SSE41-NEXT: shrl $8, %eax +; SSE41-NEXT: addb %cl, %al +; SSE41-NEXT: # kill: def $al killed $al killed $eax +; SSE41-NEXT: retq +; ; AVX1-LABEL: bitcast_v16i16_to_v2i8: ; AVX1: # %bb.0: ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 @@ -267,14 +496,65 @@ define i8 @bitcast_v16i16_to_v2i8(<16 x i16> %a0) nounwind { ret i8 %5 } +define i1 @trunc_v16i16_cmp(<16 x i16> %a0) nounwind { +; SSE-LABEL: trunc_v16i16_cmp: +; SSE: # %bb.0: +; SSE-NEXT: movdqa {{.*#+}} xmm2 = [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0] +; SSE-NEXT: pand %xmm2, %xmm1 +; SSE-NEXT: pand %xmm2, %xmm0 +; SSE-NEXT: packuswb %xmm1, %xmm0 +; SSE-NEXT: psllw $7, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: testl %eax, %eax +; SSE-NEXT: sete %al +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_v16i16_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 +; AVX1-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: testl %eax, %eax +; AVX1-NEXT: sete %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v16i16_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0 +; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 +; AVX2-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX2-NEXT: vpmovmskb %xmm0, %eax +; AVX2-NEXT: testl %eax, %eax +; AVX2-NEXT: sete %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v16i16_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $15, %ymm0, %ymm0 +; AVX512-NEXT: vpmovw2m %ymm0, %k0 +; AVX512-NEXT: kortestw %k0, %k0 +; AVX512-NEXT: sete %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <16 x i16> %a0 to <16 x i1> + %2 = bitcast <16 x i1> %1 to i16 + %3 = icmp eq i16 %2, 0 + ret i1 %3 +} + define i16 @bitcast_v32i8_to_v2i16(<32 x i8> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v32i8_to_v2i16: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: pmovmskb %xmm1, %ecx -; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: addl %ecx, %eax -; SSE2-SSSE3-NEXT: # kill: def $ax killed $ax killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v32i8_to_v2i16: +; SSE: # %bb.0: +; SSE-NEXT: pmovmskb %xmm1, %ecx +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: addl %ecx, %eax +; SSE-NEXT: # kill: def $ax killed $ax killed $eax +; SSE-NEXT: retq ; ; AVX1-LABEL: bitcast_v32i8_to_v2i16: ; AVX1: # %bb.0: @@ -314,24 +594,68 @@ define i16 @bitcast_v32i8_to_v2i16(<32 x i8> %a0) nounwind { ret i16 %5 } +define i1 @trunc_v32i8_cmp(<32 x i8> %a0) nounwind { +; SSE-LABEL: trunc_v32i8_cmp: +; SSE: # %bb.0: +; SSE-NEXT: pand %xmm1, %xmm0 +; SSE-NEXT: psllw $7, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: sete %al +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_v32i8_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1 +; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: sete %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v32i8_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsllw $7, %ymm0, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %eax +; AVX2-NEXT: cmpl $-1, %eax +; AVX2-NEXT: sete %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v32i8_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $7, %ymm0, %ymm0 +; AVX512-NEXT: vpmovmskb %ymm0, %eax +; AVX512-NEXT: cmpl $-1, %eax +; AVX512-NEXT: sete %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <32 x i8> %a0 to <32 x i1> + %2 = bitcast <32 x i1> %1 to i32 + %3 = icmp eq i32 %2, -1 + ret i1 %3 +} + ; ; 512-bit vectors ; define i4 @bitcast_v8i64_to_v2i4(<8 x i64> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v8i64_to_v2i4: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: packssdw %xmm3, %xmm2 -; SSE2-SSSE3-NEXT: packssdw %xmm1, %xmm0 -; SSE2-SSSE3-NEXT: packssdw %xmm2, %xmm0 -; SSE2-SSSE3-NEXT: packsswb %xmm0, %xmm0 -; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %ecx -; SSE2-SSSE3-NEXT: shrb $4, %cl -; SSE2-SSSE3-NEXT: andb $15, %al -; SSE2-SSSE3-NEXT: addb %cl, %al -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v8i64_to_v2i4: +; SSE: # %bb.0: +; SSE-NEXT: packssdw %xmm3, %xmm2 +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: packssdw %xmm2, %xmm0 +; SSE-NEXT: packsswb %xmm0, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: movl %eax, %ecx +; SSE-NEXT: shrb $4, %cl +; SSE-NEXT: andb $15, %al +; SSE-NEXT: addb %cl, %al +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: retq ; ; AVX1-LABEL: bitcast_v8i64_to_v2i4: ; AVX1: # %bb.0: @@ -385,6 +709,85 @@ define i4 @bitcast_v8i64_to_v2i4(<8 x i64> %a0) nounwind { ret i4 %5 } +define i1 @trunc_v8i64_cmp(<8 x i64> %a0) nounwind { +; SSE2-SSSE3-LABEL: trunc_v8i64_cmp: +; SSE2-SSSE3: # %bb.0: +; SSE2-SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] +; SSE2-SSSE3-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,2,2,3,4,5,6,7] +; SSE2-SSSE3-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3] +; SSE2-SSSE3-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7] +; SSE2-SSSE3-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1] +; SSE2-SSSE3-NEXT: pshufd {{.*#+}} xmm1 = xmm3[0,2,2,3] +; SSE2-SSSE3-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,1,0,2,4,5,6,7] +; SSE2-SSSE3-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] +; SSE2-SSSE3-NEXT: pshuflw {{.*#+}} xmm2 = xmm2[0,1,0,2,4,5,6,7] +; SSE2-SSSE3-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] +; SSE2-SSSE3-NEXT: movsd {{.*#+}} xmm2 = xmm0[0],xmm2[1] +; SSE2-SSSE3-NEXT: psllw $15, %xmm2 +; SSE2-SSSE3-NEXT: packsswb %xmm2, %xmm2 +; SSE2-SSSE3-NEXT: pmovmskb %xmm2, %eax +; SSE2-SSSE3-NEXT: cmpb $-1, %al +; SSE2-SSSE3-NEXT: sete %al +; SSE2-SSSE3-NEXT: retq +; +; SSE41-LABEL: trunc_v8i64_cmp: +; SSE41: # %bb.0: +; SSE41-NEXT: pxor %xmm4, %xmm4 +; SSE41-NEXT: pblendw {{.*#+}} xmm3 = xmm3[0],xmm4[1,2,3],xmm3[4],xmm4[5,6,7] +; SSE41-NEXT: pblendw {{.*#+}} xmm2 = xmm2[0],xmm4[1,2,3],xmm2[4],xmm4[5,6,7] +; SSE41-NEXT: packusdw %xmm3, %xmm2 +; SSE41-NEXT: pblendw {{.*#+}} xmm1 = xmm1[0],xmm4[1,2,3],xmm1[4],xmm4[5,6,7] +; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0],xmm4[1,2,3],xmm0[4],xmm4[5,6,7] +; SSE41-NEXT: packusdw %xmm1, %xmm0 +; SSE41-NEXT: packusdw %xmm2, %xmm0 +; SSE41-NEXT: psllw $15, %xmm0 +; SSE41-NEXT: packsswb %xmm0, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %eax +; SSE41-NEXT: cmpb $-1, %al +; SSE41-NEXT: sete %al +; SSE41-NEXT: retq +; +; AVX1-LABEL: trunc_v8i64_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vshufps {{.*#+}} xmm1 = xmm1[0,2],xmm2[0,2] +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[0,2] +; AVX1-NEXT: vandps %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpslld $31, %xmm0, %xmm0 +; AVX1-NEXT: vmovmskps %xmm0, %eax +; AVX1-NEXT: cmpl $15, %eax +; AVX1-NEXT: sete %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v8i64_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vperm2f128 {{.*#+}} ymm2 = ymm0[2,3],ymm1[2,3] +; AVX2-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0 +; AVX2-NEXT: vshufps {{.*#+}} ymm0 = ymm0[0,2],ymm2[0,2],ymm0[4,6],ymm2[4,6] +; AVX2-NEXT: vpslld $31, %ymm0, %ymm0 +; AVX2-NEXT: vmovmskps %ymm0, %eax +; AVX2-NEXT: cmpb $-1, %al +; AVX2-NEXT: sete %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v8i64_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllq $63, %zmm0, %zmm0 +; AVX512-NEXT: vptestmq %zmm0, %zmm0, %k0 +; AVX512-NEXT: kmovd %k0, %eax +; AVX512-NEXT: cmpb $-1, %al +; AVX512-NEXT: sete %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <8 x i64> %a0 to <8 x i1> + %2 = bitcast <8 x i1> %1 to i8 + %3 = icmp eq i8 %2, -1 + ret i1 %3 +} + define i8 @bitcast_v16i32_to_v2i8(<16 x i32> %a0) nounwind { ; SSE2-SSSE3-LABEL: bitcast_v16i32_to_v2i8: ; SSE2-SSSE3: # %bb.0: @@ -398,6 +801,18 @@ define i8 @bitcast_v16i32_to_v2i8(<16 x i32> %a0) nounwind { ; SSE2-SSSE3-NEXT: addb -{{[0-9]+}}(%rsp), %al ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: bitcast_v16i32_to_v2i8: +; SSE41: # %bb.0: +; SSE41-NEXT: packssdw %xmm3, %xmm2 +; SSE41-NEXT: packssdw %xmm1, %xmm0 +; SSE41-NEXT: packsswb %xmm2, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %ecx +; SSE41-NEXT: movl %ecx, %eax +; SSE41-NEXT: shrl $8, %eax +; SSE41-NEXT: addb %cl, %al +; SSE41-NEXT: # kill: def $al killed $al killed $eax +; SSE41-NEXT: retq +; ; AVX1-LABEL: bitcast_v16i32_to_v2i8: ; AVX1: # %bb.0: ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 @@ -449,17 +864,97 @@ define i8 @bitcast_v16i32_to_v2i8(<16 x i32> %a0) nounwind { ret i8 %5 } -define i16 @bitcast_v32i16_to_v2i16(<32 x i16> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v32i16_to_v2i16: +define i1 @trunc_v16i32_cmp(<16 x i32> %a0) nounwind { +; SSE2-SSSE3-LABEL: trunc_v16i32_cmp: ; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: packsswb %xmm3, %xmm2 -; SSE2-SSSE3-NEXT: pmovmskb %xmm2, %ecx -; SSE2-SSSE3-NEXT: packsswb %xmm1, %xmm0 +; SSE2-SSSE3-NEXT: movdqa {{.*#+}} xmm4 = [255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0] +; SSE2-SSSE3-NEXT: pand %xmm4, %xmm3 +; SSE2-SSSE3-NEXT: pand %xmm4, %xmm2 +; SSE2-SSSE3-NEXT: packuswb %xmm3, %xmm2 +; SSE2-SSSE3-NEXT: pand %xmm4, %xmm1 +; SSE2-SSSE3-NEXT: pand %xmm4, %xmm0 +; SSE2-SSSE3-NEXT: packuswb %xmm1, %xmm0 +; SSE2-SSSE3-NEXT: packuswb %xmm2, %xmm0 +; SSE2-SSSE3-NEXT: psllw $7, %xmm0 ; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: addl %ecx, %eax -; SSE2-SSSE3-NEXT: # kill: def $ax killed $ax killed $eax +; SSE2-SSSE3-NEXT: testl %eax, %eax +; SSE2-SSSE3-NEXT: sete %al ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: trunc_v16i32_cmp: +; SSE41: # %bb.0: +; SSE41-NEXT: movdqa {{.*#+}} xmm4 = [255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,0] +; SSE41-NEXT: pand %xmm4, %xmm3 +; SSE41-NEXT: pand %xmm4, %xmm2 +; SSE41-NEXT: packusdw %xmm3, %xmm2 +; SSE41-NEXT: pand %xmm4, %xmm1 +; SSE41-NEXT: pand %xmm4, %xmm0 +; SSE41-NEXT: packusdw %xmm1, %xmm0 +; SSE41-NEXT: packuswb %xmm2, %xmm0 +; SSE41-NEXT: psllw $7, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %eax +; SSE41-NEXT: testl %eax, %eax +; SSE41-NEXT: sete %al +; SSE41-NEXT: retq +; +; AVX1-LABEL: trunc_v16i32_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vmovaps {{.*#+}} ymm2 = [255,255,255,255,255,255,255,255] +; AVX1-NEXT: vandps %ymm2, %ymm1, %ymm1 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm3 +; AVX1-NEXT: vpackusdw %xmm3, %xmm1, %xmm1 +; AVX1-NEXT: vandps %ymm2, %ymm0, %ymm0 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2 +; AVX1-NEXT: vpackusdw %xmm2, %xmm0, %xmm0 +; AVX1-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: testl %eax, %eax +; AVX1-NEXT: sete %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v16i32_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpbroadcastd {{.*#+}} ymm2 = [255,255,255,255,255,255,255,255] +; AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1 +; AVX2-NEXT: vpand %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpackusdw %ymm1, %ymm0, %ymm0 +; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 +; AVX2-NEXT: vpackuswb %xmm1, %xmm0, %xmm0 +; AVX2-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,1,3] +; AVX2-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX2-NEXT: vpmovmskb %xmm0, %eax +; AVX2-NEXT: testl %eax, %eax +; AVX2-NEXT: sete %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v16i32_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpslld $31, %zmm0, %zmm0 +; AVX512-NEXT: vptestmd %zmm0, %zmm0, %k0 +; AVX512-NEXT: kortestw %k0, %k0 +; AVX512-NEXT: sete %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <16 x i32> %a0 to <16 x i1> + %2 = bitcast <16 x i1> %1 to i16 + %3 = icmp eq i16 %2, 0 + ret i1 %3 +} + +define i16 @bitcast_v32i16_to_v2i16(<32 x i16> %a0) nounwind { +; SSE-LABEL: bitcast_v32i16_to_v2i16: +; SSE: # %bb.0: +; SSE-NEXT: packsswb %xmm3, %xmm2 +; SSE-NEXT: pmovmskb %xmm2, %ecx +; SSE-NEXT: packsswb %xmm1, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: addl %ecx, %eax +; SSE-NEXT: # kill: def $ax killed $ax killed $eax +; SSE-NEXT: retq +; ; AVX1-LABEL: bitcast_v32i16_to_v2i16: ; AVX1: # %bb.0: ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 @@ -503,6 +998,68 @@ define i16 @bitcast_v32i16_to_v2i16(<32 x i16> %a0) nounwind { ret i16 %5 } +define i1 @trunc_v32i16_cmp(<32 x i16> %a0) nounwind { +; SSE-LABEL: trunc_v32i16_cmp: +; SSE: # %bb.0: +; SSE-NEXT: movdqa {{.*#+}} xmm4 = [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0] +; SSE-NEXT: pand %xmm4, %xmm1 +; SSE-NEXT: pand %xmm4, %xmm0 +; SSE-NEXT: packuswb %xmm1, %xmm0 +; SSE-NEXT: pand %xmm4, %xmm3 +; SSE-NEXT: pand %xmm4, %xmm2 +; SSE-NEXT: packuswb %xmm3, %xmm2 +; SSE-NEXT: pand %xmm0, %xmm2 +; SSE-NEXT: psllw $7, %xmm2 +; SSE-NEXT: pmovmskb %xmm2, %eax +; SSE-NEXT: cmpw $-1, %ax +; SSE-NEXT: setne %al +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_v32i16_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vmovaps {{.*#+}} ymm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255] +; AVX1-NEXT: vandps %ymm2, %ymm0, %ymm0 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm3 +; AVX1-NEXT: vpackuswb %xmm3, %xmm0, %xmm0 +; AVX1-NEXT: vandps %ymm2, %ymm1, %ymm1 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vpackuswb %xmm2, %xmm1, %xmm1 +; AVX1-NEXT: vpand %xmm0, %xmm1, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: cmpw $-1, %ax +; AVX1-NEXT: setne %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v32i16_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpbroadcastw {{.*#+}} ymm2 = [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255] +; AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1 +; AVX2-NEXT: vpand %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vpackuswb %ymm1, %ymm0, %ymm0 +; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3] +; AVX2-NEXT: vpsllw $7, %ymm0, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %eax +; AVX2-NEXT: cmpl $-1, %eax +; AVX2-NEXT: setne %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v32i16_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $15, %zmm0, %zmm0 +; AVX512-NEXT: vpmovw2m %zmm0, %k0 +; AVX512-NEXT: kortestd %k0, %k0 +; AVX512-NEXT: setae %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <32 x i16> %a0 to <32 x i1> + %2 = bitcast <32 x i1> %1 to i32 + %3 = icmp ne i32 %2, -1 + ret i1 %3 +} + define i32 @bitcast_v64i8_to_v2i32(<64 x i8> %a0) nounwind { ; SSE2-SSSE3-LABEL: bitcast_v64i8_to_v2i32: ; SSE2-SSSE3: # %bb.0: @@ -522,6 +1079,19 @@ define i32 @bitcast_v64i8_to_v2i32(<64 x i8> %a0) nounwind { ; SSE2-SSSE3-NEXT: addl %ecx, %eax ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: bitcast_v64i8_to_v2i32: +; SSE41: # %bb.0: +; SSE41-NEXT: pmovmskb %xmm2, %eax +; SSE41-NEXT: pmovmskb %xmm3, %ecx +; SSE41-NEXT: shll $16, %ecx +; SSE41-NEXT: orl %eax, %ecx +; SSE41-NEXT: pmovmskb %xmm0, %edx +; SSE41-NEXT: pmovmskb %xmm1, %eax +; SSE41-NEXT: shll $16, %eax +; SSE41-NEXT: orl %edx, %eax +; SSE41-NEXT: addl %ecx, %eax +; SSE41-NEXT: retq +; ; AVX1-LABEL: bitcast_v64i8_to_v2i32: ; AVX1: # %bb.0: ; AVX1-NEXT: vpmovmskb %xmm1, %eax @@ -563,31 +1133,81 @@ define i32 @bitcast_v64i8_to_v2i32(<64 x i8> %a0) nounwind { ret i32 %5 } +define i1 @trunc_v64i8_cmp(<64 x i8> %a0) nounwind { +; SSE-LABEL: trunc_v64i8_cmp: +; SSE: # %bb.0: +; SSE-NEXT: por %xmm3, %xmm1 +; SSE-NEXT: por %xmm2, %xmm0 +; SSE-NEXT: por %xmm1, %xmm0 +; SSE-NEXT: psllw $7, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: testl %eax, %eax +; SSE-NEXT: setne %al +; SSE-NEXT: retq +; +; AVX1-LABEL: trunc_v64i8_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm2 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm3 +; AVX1-NEXT: vpor %xmm2, %xmm3, %xmm2 +; AVX1-NEXT: vpor %xmm1, %xmm0, %xmm0 +; AVX1-NEXT: vpor %xmm2, %xmm0, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: testl %eax, %eax +; AVX1-NEXT: setne %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v64i8_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0 +; AVX2-NEXT: vpsllw $7, %ymm0, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %eax +; AVX2-NEXT: testl %eax, %eax +; AVX2-NEXT: setne %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v64i8_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $7, %zmm0, %zmm0 +; AVX512-NEXT: vpmovb2m %zmm0, %k0 +; AVX512-NEXT: kortestq %k0, %k0 +; AVX512-NEXT: setne %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <64 x i8> %a0 to <64 x i1> + %2 = bitcast <64 x i1> %1 to i64 + %3 = icmp ne i64 %2, 0 + ret i1 %3 +} + define i64 @bitcast_v128i8_to_v2i64(<128 x i8> %a0) nounwind { -; SSE2-SSSE3-LABEL: bitcast_v128i8_to_v2i64: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: pmovmskb %xmm4, %eax -; SSE2-SSSE3-NEXT: pmovmskb %xmm5, %ecx -; SSE2-SSSE3-NEXT: shll $16, %ecx -; SSE2-SSSE3-NEXT: orl %eax, %ecx -; SSE2-SSSE3-NEXT: pmovmskb %xmm6, %eax -; SSE2-SSSE3-NEXT: pmovmskb %xmm7, %edx -; SSE2-SSSE3-NEXT: shll $16, %edx -; SSE2-SSSE3-NEXT: orl %eax, %edx -; SSE2-SSSE3-NEXT: shlq $32, %rdx -; SSE2-SSSE3-NEXT: orq %rcx, %rdx -; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: pmovmskb %xmm1, %ecx -; SSE2-SSSE3-NEXT: shll $16, %ecx -; SSE2-SSSE3-NEXT: orl %eax, %ecx -; SSE2-SSSE3-NEXT: pmovmskb %xmm2, %esi -; SSE2-SSSE3-NEXT: pmovmskb %xmm3, %eax -; SSE2-SSSE3-NEXT: shll $16, %eax -; SSE2-SSSE3-NEXT: orl %esi, %eax -; SSE2-SSSE3-NEXT: shlq $32, %rax -; SSE2-SSSE3-NEXT: orq %rcx, %rax -; SSE2-SSSE3-NEXT: addq %rdx, %rax -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: bitcast_v128i8_to_v2i64: +; SSE: # %bb.0: +; SSE-NEXT: pmovmskb %xmm4, %eax +; SSE-NEXT: pmovmskb %xmm5, %ecx +; SSE-NEXT: shll $16, %ecx +; SSE-NEXT: orl %eax, %ecx +; SSE-NEXT: pmovmskb %xmm6, %eax +; SSE-NEXT: pmovmskb %xmm7, %edx +; SSE-NEXT: shll $16, %edx +; SSE-NEXT: orl %eax, %edx +; SSE-NEXT: shlq $32, %rdx +; SSE-NEXT: orq %rcx, %rdx +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: pmovmskb %xmm1, %ecx +; SSE-NEXT: shll $16, %ecx +; SSE-NEXT: orl %eax, %ecx +; SSE-NEXT: pmovmskb %xmm2, %esi +; SSE-NEXT: pmovmskb %xmm3, %eax +; SSE-NEXT: shll $16, %eax +; SSE-NEXT: orl %esi, %eax +; SSE-NEXT: shlq $32, %rax +; SSE-NEXT: orq %rcx, %rax +; SSE-NEXT: addq %rdx, %rax +; SSE-NEXT: retq ; ; AVX1-LABEL: bitcast_v128i8_to_v2i64: ; AVX1: # %bb.0: @@ -650,24 +1270,191 @@ define i64 @bitcast_v128i8_to_v2i64(<128 x i8> %a0) nounwind { ret i64 %5 } -define [2 x i8] @PR58546(<16 x float> %a0) { -; SSE2-SSSE3-LABEL: PR58546: +define i1 @trunc_v128i8_cmp(<128 x i8> %a0) nounwind { +; SSE2-SSSE3-LABEL: trunc_v128i8_cmp: ; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: xorps %xmm4, %xmm4 -; SSE2-SSSE3-NEXT: cmpunordps %xmm4, %xmm3 -; SSE2-SSSE3-NEXT: cmpunordps %xmm4, %xmm2 -; SSE2-SSSE3-NEXT: packssdw %xmm3, %xmm2 -; SSE2-SSSE3-NEXT: cmpunordps %xmm4, %xmm1 -; SSE2-SSSE3-NEXT: cmpunordps %xmm4, %xmm0 -; SSE2-SSSE3-NEXT: packssdw %xmm1, %xmm0 -; SSE2-SSSE3-NEXT: packsswb %xmm2, %xmm0 +; SSE2-SSSE3-NEXT: psllw $7, %xmm0 +; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax +; SSE2-SSSE3-NEXT: psllw $7, %xmm1 +; SSE2-SSSE3-NEXT: pmovmskb %xmm1, %ecx +; SSE2-SSSE3-NEXT: shll $16, %ecx +; SSE2-SSSE3-NEXT: orl %eax, %ecx +; SSE2-SSSE3-NEXT: psllw $7, %xmm2 +; SSE2-SSSE3-NEXT: pmovmskb %xmm2, %edx +; SSE2-SSSE3-NEXT: psllw $7, %xmm3 +; SSE2-SSSE3-NEXT: pmovmskb %xmm3, %eax +; SSE2-SSSE3-NEXT: shll $16, %eax +; SSE2-SSSE3-NEXT: orl %edx, %eax +; SSE2-SSSE3-NEXT: shlq $32, %rax +; SSE2-SSSE3-NEXT: orq %rcx, %rax +; SSE2-SSSE3-NEXT: psllw $7, %xmm4 +; SSE2-SSSE3-NEXT: pmovmskb %xmm4, %ecx +; SSE2-SSSE3-NEXT: psllw $7, %xmm5 +; SSE2-SSSE3-NEXT: pmovmskb %xmm5, %edx +; SSE2-SSSE3-NEXT: shll $16, %edx +; SSE2-SSSE3-NEXT: orl %ecx, %edx +; SSE2-SSSE3-NEXT: psllw $7, %xmm6 +; SSE2-SSSE3-NEXT: pmovmskb %xmm6, %ecx +; SSE2-SSSE3-NEXT: psllw $7, %xmm7 +; SSE2-SSSE3-NEXT: pmovmskb %xmm7, %esi +; SSE2-SSSE3-NEXT: shll $16, %esi +; SSE2-SSSE3-NEXT: orl %ecx, %esi +; SSE2-SSSE3-NEXT: shlq $32, %rsi +; SSE2-SSSE3-NEXT: orq %rdx, %rsi +; SSE2-SSSE3-NEXT: movq %rsi, %xmm0 +; SSE2-SSSE3-NEXT: movq %rax, %xmm1 +; SSE2-SSSE3-NEXT: punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0] +; SSE2-SSSE3-NEXT: pcmpeqd %xmm0, %xmm0 +; SSE2-SSSE3-NEXT: pcmpeqb %xmm1, %xmm0 ; SSE2-SSSE3-NEXT: pmovmskb %xmm0, %eax -; SSE2-SSSE3-NEXT: movl %eax, %edx -; SSE2-SSSE3-NEXT: shrl $8, %edx -; SSE2-SSSE3-NEXT: # kill: def $al killed $al killed $eax -; SSE2-SSSE3-NEXT: # kill: def $dl killed $dl killed $edx +; SSE2-SSSE3-NEXT: cmpl $65535, %eax # imm = 0xFFFF +; SSE2-SSSE3-NEXT: setne %al ; SSE2-SSSE3-NEXT: retq ; +; SSE41-LABEL: trunc_v128i8_cmp: +; SSE41: # %bb.0: +; SSE41-NEXT: psllw $7, %xmm0 +; SSE41-NEXT: pmovmskb %xmm0, %eax +; SSE41-NEXT: psllw $7, %xmm1 +; SSE41-NEXT: pmovmskb %xmm1, %ecx +; SSE41-NEXT: shll $16, %ecx +; SSE41-NEXT: orl %eax, %ecx +; SSE41-NEXT: psllw $7, %xmm2 +; SSE41-NEXT: pmovmskb %xmm2, %edx +; SSE41-NEXT: psllw $7, %xmm3 +; SSE41-NEXT: pmovmskb %xmm3, %eax +; SSE41-NEXT: shll $16, %eax +; SSE41-NEXT: orl %edx, %eax +; SSE41-NEXT: shlq $32, %rax +; SSE41-NEXT: orq %rcx, %rax +; SSE41-NEXT: psllw $7, %xmm4 +; SSE41-NEXT: pmovmskb %xmm4, %ecx +; SSE41-NEXT: psllw $7, %xmm5 +; SSE41-NEXT: pmovmskb %xmm5, %edx +; SSE41-NEXT: shll $16, %edx +; SSE41-NEXT: orl %ecx, %edx +; SSE41-NEXT: psllw $7, %xmm6 +; SSE41-NEXT: pmovmskb %xmm6, %ecx +; SSE41-NEXT: psllw $7, %xmm7 +; SSE41-NEXT: pmovmskb %xmm7, %esi +; SSE41-NEXT: shll $16, %esi +; SSE41-NEXT: orl %ecx, %esi +; SSE41-NEXT: shlq $32, %rsi +; SSE41-NEXT: orq %rdx, %rsi +; SSE41-NEXT: movq %rsi, %xmm0 +; SSE41-NEXT: movq %rax, %xmm1 +; SSE41-NEXT: punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0] +; SSE41-NEXT: pcmpeqd %xmm0, %xmm0 +; SSE41-NEXT: ptest %xmm0, %xmm1 +; SSE41-NEXT: setae %al +; SSE41-NEXT: retq +; +; AVX1-LABEL: trunc_v128i8_cmp: +; AVX1: # %bb.0: +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm4 +; AVX1-NEXT: vpmovmskb %xmm4, %eax +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %ecx +; AVX1-NEXT: shll $16, %ecx +; AVX1-NEXT: orl %eax, %ecx +; AVX1-NEXT: vpsllw $7, %xmm1, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %edx +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: shll $16, %eax +; AVX1-NEXT: orl %edx, %eax +; AVX1-NEXT: shlq $32, %rax +; AVX1-NEXT: orq %rcx, %rax +; AVX1-NEXT: vpsllw $7, %xmm2, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %ecx +; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %edx +; AVX1-NEXT: shll $16, %edx +; AVX1-NEXT: orl %ecx, %edx +; AVX1-NEXT: vpsllw $7, %xmm3, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %ecx +; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm0 +; AVX1-NEXT: vpsllw $7, %xmm0, %xmm0 +; AVX1-NEXT: vpmovmskb %xmm0, %esi +; AVX1-NEXT: shll $16, %esi +; AVX1-NEXT: orl %ecx, %esi +; AVX1-NEXT: shlq $32, %rsi +; AVX1-NEXT: orq %rdx, %rsi +; AVX1-NEXT: vmovq %rsi, %xmm0 +; AVX1-NEXT: vmovq %rax, %xmm1 +; AVX1-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm1[0],xmm0[0] +; AVX1-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1 +; AVX1-NEXT: vptest %xmm1, %xmm0 +; AVX1-NEXT: setae %al +; AVX1-NEXT: vzeroupper +; AVX1-NEXT: retq +; +; AVX2-LABEL: trunc_v128i8_cmp: +; AVX2: # %bb.0: +; AVX2-NEXT: vpsllw $7, %ymm1, %ymm1 +; AVX2-NEXT: vpmovmskb %ymm1, %eax +; AVX2-NEXT: shlq $32, %rax +; AVX2-NEXT: vpsllw $7, %ymm0, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %ecx +; AVX2-NEXT: orq %rax, %rcx +; AVX2-NEXT: vpsllw $7, %ymm3, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %eax +; AVX2-NEXT: shlq $32, %rax +; AVX2-NEXT: vpsllw $7, %ymm2, %ymm0 +; AVX2-NEXT: vpmovmskb %ymm0, %edx +; AVX2-NEXT: orq %rax, %rdx +; AVX2-NEXT: vmovq %rdx, %xmm0 +; AVX2-NEXT: vmovq %rcx, %xmm1 +; AVX2-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm1[0],xmm0[0] +; AVX2-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1 +; AVX2-NEXT: vptest %xmm1, %xmm0 +; AVX2-NEXT: setae %al +; AVX2-NEXT: vzeroupper +; AVX2-NEXT: retq +; +; AVX512-LABEL: trunc_v128i8_cmp: +; AVX512: # %bb.0: +; AVX512-NEXT: vpsllw $7, %zmm0, %zmm0 +; AVX512-NEXT: vpmovb2m %zmm0, %k0 +; AVX512-NEXT: kmovq %k0, %rax +; AVX512-NEXT: vpsllw $7, %zmm1, %zmm0 +; AVX512-NEXT: vpmovb2m %zmm0, %k0 +; AVX512-NEXT: kmovq %k0, %rcx +; AVX512-NEXT: vmovq %rcx, %xmm0 +; AVX512-NEXT: vmovq %rax, %xmm1 +; AVX512-NEXT: vpunpcklqdq {{.*#+}} xmm0 = xmm1[0],xmm0[0] +; AVX512-NEXT: vpcmpeqd %xmm1, %xmm1, %xmm1 +; AVX512-NEXT: vptest %xmm1, %xmm0 +; AVX512-NEXT: setae %al +; AVX512-NEXT: vzeroupper +; AVX512-NEXT: retq + %1 = trunc <128 x i8> %a0 to <128 x i1> + %2 = bitcast <128 x i1> %1 to i128 + %3 = icmp ne i128 %2, -1 + ret i1 %3 +} + +define [2 x i8] @PR58546(<16 x float> %a0) { +; SSE-LABEL: PR58546: +; SSE: # %bb.0: +; SSE-NEXT: xorps %xmm4, %xmm4 +; SSE-NEXT: cmpunordps %xmm4, %xmm3 +; SSE-NEXT: cmpunordps %xmm4, %xmm2 +; SSE-NEXT: packssdw %xmm3, %xmm2 +; SSE-NEXT: cmpunordps %xmm4, %xmm1 +; SSE-NEXT: cmpunordps %xmm4, %xmm0 +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: packsswb %xmm2, %xmm0 +; SSE-NEXT: pmovmskb %xmm0, %eax +; SSE-NEXT: movl %eax, %edx +; SSE-NEXT: shrl $8, %edx +; SSE-NEXT: # kill: def $al killed $al killed $eax +; SSE-NEXT: # kill: def $dl killed $dl killed $edx +; SSE-NEXT: retq +; ; AVX1-LABEL: PR58546: ; AVX1: # %bb.0: ; AVX1-NEXT: vxorps %xmm2, %xmm2, %xmm2 @@ -724,23 +1511,23 @@ define [2 x i8] @PR58546(<16 x float> %a0) { } define i8 @PR59526(<8 x i32> %a, <8 x i32> %b, ptr %mask) { -; SSE2-SSSE3-LABEL: PR59526: -; SSE2-SSSE3: # %bb.0: -; SSE2-SSSE3-NEXT: pcmpeqd %xmm3, %xmm1 -; SSE2-SSSE3-NEXT: pcmpeqd %xmm2, %xmm0 -; SSE2-SSSE3-NEXT: packssdw %xmm1, %xmm0 -; SSE2-SSSE3-NEXT: movdqu (%rdi), %xmm1 -; SSE2-SSSE3-NEXT: movdqu 16(%rdi), %xmm2 -; SSE2-SSSE3-NEXT: pxor %xmm3, %xmm3 -; SSE2-SSSE3-NEXT: pxor %xmm4, %xmm4 -; SSE2-SSSE3-NEXT: pcmpgtd %xmm2, %xmm4 -; SSE2-SSSE3-NEXT: pcmpgtd %xmm1, %xmm3 -; SSE2-SSSE3-NEXT: packssdw %xmm4, %xmm3 -; SSE2-SSSE3-NEXT: pand %xmm0, %xmm3 -; SSE2-SSSE3-NEXT: pmovmskb %xmm3, %eax -; SSE2-SSSE3-NEXT: testl %eax, %eax -; SSE2-SSSE3-NEXT: setne %al -; SSE2-SSSE3-NEXT: retq +; SSE-LABEL: PR59526: +; SSE: # %bb.0: +; SSE-NEXT: pcmpeqd %xmm3, %xmm1 +; SSE-NEXT: pcmpeqd %xmm2, %xmm0 +; SSE-NEXT: packssdw %xmm1, %xmm0 +; SSE-NEXT: movdqu (%rdi), %xmm1 +; SSE-NEXT: movdqu 16(%rdi), %xmm2 +; SSE-NEXT: pxor %xmm3, %xmm3 +; SSE-NEXT: pxor %xmm4, %xmm4 +; SSE-NEXT: pcmpgtd %xmm2, %xmm4 +; SSE-NEXT: pcmpgtd %xmm1, %xmm3 +; SSE-NEXT: packssdw %xmm4, %xmm3 +; SSE-NEXT: pand %xmm0, %xmm3 +; SSE-NEXT: pmovmskb %xmm3, %eax +; SSE-NEXT: testl %eax, %eax +; SSE-NEXT: setne %al +; SSE-NEXT: retq ; ; AVX1-LABEL: PR59526: ; AVX1: # %bb.0: