From 7b54a29c2e72e3e6bf7bb8cb5acfe254335584d7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 6 Mar 2023 16:13:58 +0000 Subject: [PATCH] [X86] combineBitcastvxi1/checkBitcastSrcVectorSize - sign-extend vXi1 allones vselect operands Minor fix to Issue #61104 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 4 ++-- llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index ac74375..26b6866 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -43676,8 +43676,8 @@ static bool checkBitcastSrcVectorSize(SDValue Src, unsigned Size, checkBitcastSrcVectorSize(Src.getOperand(1), Size, AllowTruncate) && checkBitcastSrcVectorSize(Src.getOperand(2), Size, AllowTruncate); case ISD::BUILD_VECTOR: - return ISD::isBuildVectorAllZeros(Src.getNode()); - + return ISD::isBuildVectorAllZeros(Src.getNode()) || + ISD::isBuildVectorAllOnes(Src.getNode()); } return false; } diff --git a/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll b/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll index 3b04da9..e092bf5 100644 --- a/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll +++ b/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll @@ -463,16 +463,13 @@ define i8 @v8i32_or_select(<8 x i32> %a0, <8 x i32> %a1, <8 x i32> %a2) { ; ; AVX1-LABEL: v8i32_or_select: ; AVX1: # %bb.0: -; AVX1-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm3 -; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1 -; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm0 +; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm3 +; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm4 +; AVX1-NEXT: vpcmpeqd %xmm3, %xmm4, %xmm3 ; AVX1-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0 -; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm1 -; AVX1-NEXT: vpor %xmm1, %xmm0, %xmm0 -; AVX1-NEXT: vpor %xmm2, %xmm3, %xmm1 -; AVX1-NEXT: vpackssdw %xmm0, %xmm1, %xmm0 -; AVX1-NEXT: vpacksswb %xmm0, %xmm0, %xmm0 -; AVX1-NEXT: vpmovmskb %xmm0, %eax +; AVX1-NEXT: vinsertf128 $1, %xmm3, %ymm0, %ymm0 +; AVX1-NEXT: vorps %ymm2, %ymm0, %ymm0 +; AVX1-NEXT: vmovmskps %ymm0, %eax ; AVX1-NEXT: # kill: def $al killed $al killed $eax ; AVX1-NEXT: vzeroupper ; AVX1-NEXT: retq @@ -480,13 +477,8 @@ define i8 @v8i32_or_select(<8 x i32> %a0, <8 x i32> %a1, <8 x i32> %a2) { ; AVX2-LABEL: v8i32_or_select: ; AVX2: # %bb.0: ; AVX2-NEXT: vpcmpeqd %ymm1, %ymm0, %ymm0 -; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 -; AVX2-NEXT: vpcmpgtd %ymm2, %ymm1, %ymm1 -; AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0 -; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm1 -; AVX2-NEXT: vpackssdw %xmm1, %xmm0, %xmm0 -; AVX2-NEXT: vpacksswb %xmm0, %xmm0, %xmm0 -; AVX2-NEXT: vpmovmskb %xmm0, %eax +; AVX2-NEXT: vpor %ymm2, %ymm0, %ymm0 +; AVX2-NEXT: vmovmskps %ymm0, %eax ; AVX2-NEXT: # kill: def $al killed $al killed $eax ; AVX2-NEXT: vzeroupper ; AVX2-NEXT: retq -- 2.7.4