[llvm] e0cd60f - [X86] combineBitcastvxi1/checkBitcastSrcVectorSize - sign-extend select(i1,vXi1,vXi1) patterns
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 10:22:56 PST 2023
Author: Simon Pilgrim
Date: 2023-03-06T18:22:42Z
New Revision: e0cd60f1d5d4c73f393f842b92882ffaedd1d0be
URL: https://github.com/llvm/llvm-project/commit/e0cd60f1d5d4c73f393f842b92882ffaedd1d0be
DIFF: https://github.com/llvm/llvm-project/commit/e0cd60f1d5d4c73f393f842b92882ffaedd1d0be.diff
LOG: [X86] combineBitcastvxi1/checkBitcastSrcVectorSize - sign-extend select(i1,vXi1,vXi1) patterns
Fixes #61104
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 3862f95d91d2..d3e4dbc99b41 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -43671,6 +43671,7 @@ static bool checkBitcastSrcVectorSize(SDValue Src, unsigned Size,
case ISD::OR:
return checkBitcastSrcVectorSize(Src.getOperand(0), Size, AllowTruncate) &&
checkBitcastSrcVectorSize(Src.getOperand(1), Size, AllowTruncate);
+ case ISD::SELECT:
case ISD::VSELECT:
return Src.getOperand(0).getScalarValueSizeInBits() == 1 &&
checkBitcastSrcVectorSize(Src.getOperand(1), Size, AllowTruncate) &&
@@ -43742,6 +43743,7 @@ static SDValue signExtendBitcastSrcVector(SelectionDAG &DAG, EVT SExtVT,
Src.getOpcode(), DL, SExtVT,
signExtendBitcastSrcVector(DAG, SExtVT, Src.getOperand(0), DL),
signExtendBitcastSrcVector(DAG, SExtVT, Src.getOperand(1), DL));
+ case ISD::SELECT:
case ISD::VSELECT:
return DAG.getSelect(
DL, SExtVT, Src.getOperand(0),
diff --git a/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll b/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll
index 02ded5a757dd..8699f17ecd43 100644
--- a/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll
+++ b/llvm/test/CodeGen/X86/bitcast-and-setcc-256.ll
@@ -537,53 +537,43 @@ define i8 @v8i32_or_select(<8 x i32> %a0, <8 x i32> %a1, <8 x i32> %a2, <8 x i32
;
; AVX1-LABEL: v8i32_or_select:
; AVX1: # %bb.0:
-; AVX1-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm4
-; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm1
-; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm6
-; AVX1-NEXT: vpcmpeqd %xmm1, %xmm6, %xmm1
-; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm5
+; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm4
; AVX1-NEXT: testb $1, %dil
; AVX1-NEXT: jne .LBB7_1
; AVX1-NEXT: # %bb.2:
-; AVX1-NEXT: vpxor %xmm0, %xmm0, %xmm0
+; AVX1-NEXT: vxorps %xmm2, %xmm2, %xmm2
; AVX1-NEXT: jmp .LBB7_3
; AVX1-NEXT: .LBB7_1:
-; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm7
-; AVX1-NEXT: vpcmpeqd %xmm7, %xmm6, %xmm6
-; AVX1-NEXT: vpcmpeqd %xmm2, %xmm0, %xmm0
-; AVX1-NEXT: vpackssdw %xmm6, %xmm0, %xmm0
+; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm5
+; AVX1-NEXT: vpcmpeqd %xmm5, %xmm4, %xmm5
+; AVX1-NEXT: vpcmpeqd %xmm2, %xmm0, %xmm2
+; AVX1-NEXT: vinsertf128 $1, %xmm5, %ymm2, %ymm2
; AVX1-NEXT: .LBB7_3:
-; AVX1-NEXT: vpor %xmm1, %xmm5, %xmm1
-; AVX1-NEXT: vpor %xmm4, %xmm3, %xmm2
-; AVX1-NEXT: vpackssdw %xmm1, %xmm2, %xmm1
-; AVX1-NEXT: vpor %xmm0, %xmm1, %xmm0
-; AVX1-NEXT: vpacksswb %xmm0, %xmm0, %xmm0
-; AVX1-NEXT: vpmovmskb %xmm0, %eax
+; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm5
+; AVX1-NEXT: vpcmpeqd %xmm5, %xmm4, %xmm4
+; AVX1-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
+; AVX1-NEXT: vinsertf128 $1, %xmm4, %ymm0, %ymm0
+; AVX1-NEXT: vorps %ymm2, %ymm3, %ymm1
+; AVX1-NEXT: vorps %ymm0, %ymm1, %ymm0
+; AVX1-NEXT: vmovmskps %ymm0, %eax
; AVX1-NEXT: # kill: def $al killed $al killed $eax
; AVX1-NEXT: vzeroupper
; AVX1-NEXT: retq
;
; AVX2-LABEL: v8i32_or_select:
; AVX2: # %bb.0:
-; AVX2-NEXT: vpcmpeqd %ymm1, %ymm0, %ymm1
-; AVX2-NEXT: vpxor %xmm4, %xmm4, %xmm4
-; AVX2-NEXT: vpcmpgtd %ymm3, %ymm4, %ymm3
; AVX2-NEXT: testb $1, %dil
; AVX2-NEXT: jne .LBB7_1
; AVX2-NEXT: # %bb.2:
-; AVX2-NEXT: vpxor %xmm0, %xmm0, %xmm0
+; AVX2-NEXT: vpxor %xmm2, %xmm2, %xmm2
; AVX2-NEXT: jmp .LBB7_3
; AVX2-NEXT: .LBB7_1:
-; AVX2-NEXT: vpcmpeqd %ymm2, %ymm0, %ymm0
-; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
-; AVX2-NEXT: vpackssdw %xmm2, %xmm0, %xmm0
+; AVX2-NEXT: vpcmpeqd %ymm2, %ymm0, %ymm2
; AVX2-NEXT: .LBB7_3:
-; AVX2-NEXT: vpor %ymm1, %ymm3, %ymm1
-; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm2
-; AVX2-NEXT: vpackssdw %xmm2, %xmm1, %xmm1
-; AVX2-NEXT: vpor %xmm0, %xmm1, %xmm0
-; AVX2-NEXT: vpacksswb %xmm0, %xmm0, %xmm0
-; AVX2-NEXT: vpmovmskb %xmm0, %eax
+; AVX2-NEXT: vpcmpeqd %ymm1, %ymm0, %ymm0
+; AVX2-NEXT: vpor %ymm2, %ymm3, %ymm1
+; AVX2-NEXT: vpor %ymm0, %ymm1, %ymm0
+; AVX2-NEXT: vmovmskps %ymm0, %eax
; AVX2-NEXT: # kill: def $al killed $al killed $eax
; AVX2-NEXT: vzeroupper
; AVX2-NEXT: retq
More information about the llvm-commits
mailing list