[PATCH] D41119: [X86][SSE] MOVMSK only uses the sign bit from each vector element
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 09:59:18 PST 2017
RKSimon created this revision.
RKSimon added reviewers: spatel, craig.topper, zvi, andreadb.
Pass the input vector through SimplifyDemandedBits as we only need the sign bit from each vector element of MOVMSK
We'd probably get more hits if SimplifyDemandedBits was better at handling vectors...
Repository:
rL LLVM
https://reviews.llvm.org/D41119
Files:
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/setcc-lowering.ll
Index: test/CodeGen/X86/setcc-lowering.ll
===================================================================
--- test/CodeGen/X86/setcc-lowering.ll
+++ test/CodeGen/X86/setcc-lowering.ll
@@ -57,7 +57,6 @@
; AVX-NEXT: vpand %xmm0, %xmm3, %xmm3
; AVX-NEXT: vpsllw $7, %xmm3, %xmm3
; AVX-NEXT: vpand %xmm2, %xmm3, %xmm3
-; AVX-NEXT: vpcmpgtb %xmm3, %xmm1, %xmm3
; AVX-NEXT: vpmovmskb %xmm3, %eax
; AVX-NEXT: testw %ax, %ax
; AVX-NEXT: jne .LBB1_1
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -36170,6 +36170,27 @@
return SDValue();
}
+static SDValue combineMOVMSK(SDNode *N, SelectionDAG &DAG,
+ TargetLowering::DAGCombinerInfo &DCI) {
+ SDValue Src = N->getOperand(0);
+ MVT SrcVT = Src.getSimpleValueType();
+
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+ TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
+ !DCI.isBeforeLegalizeOps());
+
+ // MOVMSK only uses the MSB from each vector element.
+ KnownBits Known;
+ APInt DemandedMask(APInt::getSignMask(SrcVT.getScalarSizeInBits()));
+ if (TLI.SimplifyDemandedBits(Src, DemandedMask, Known, TLO)) {
+ DCI.AddToWorklist(Src.getNode());
+ DCI.CommitTargetLoweringOpt(TLO);
+ return SDValue(N, 0);
+ }
+
+ return SDValue();
+}
+
static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
TargetLowering::DAGCombinerInfo &DCI,
const X86Subtarget &Subtarget) {
@@ -37341,6 +37362,7 @@
case X86ISD::FMSUBADD_RND:
case X86ISD::FMADDSUB:
case X86ISD::FMSUBADD: return combineFMADDSUB(N, DAG, Subtarget);
+ case X86ISD::MOVMSK: return combineMOVMSK(N, DAG, DCI);
case X86ISD::MGATHER:
case X86ISD::MSCATTER:
case ISD::MGATHER:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41119.126567.patch
Type: text/x-patch
Size: 2017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171212/aa8a12d1/attachment.bin>
More information about the llvm-commits
mailing list