[llvm] r374724 - [X86] getTargetShuffleInputs - add KnownUndef/Zero output support
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 13 10:03:02 PDT 2019
Author: rksimon
Date: Sun Oct 13 10:03:02 2019
New Revision: 374724
URL: http://llvm.org/viewvc/llvm-project?rev=374724&view=rev
Log:
[X86] getTargetShuffleInputs - add KnownUndef/Zero output support
Adjust SimplifyDemandedVectorEltsForTargetNode to use the known elts masks instead of recomputing it locally.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=374724&r1=374723&r2=374724&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Oct 13 10:03:02 2019
@@ -7248,13 +7248,13 @@ static void resolveTargetShuffleInputsAn
static bool getTargetShuffleInputs(SDValue Op, const APInt &DemandedElts,
SmallVectorImpl<SDValue> &Inputs,
SmallVectorImpl<int> &Mask,
+ APInt &KnownUndef, APInt &KnownZero,
SelectionDAG &DAG, unsigned Depth,
bool ResolveZero) {
EVT VT = Op.getValueType();
if (!VT.isSimple() || !VT.isVector())
return false;
- APInt KnownUndef, KnownZero;
if (getTargetShuffleAndZeroables(Op, Mask, Inputs, KnownUndef, KnownZero)) {
for (int i = 0, e = Mask.size(); i != e; ++i) {
int &M = Mask[i];
@@ -7267,8 +7267,19 @@ static bool getTargetShuffleInputs(SDVal
}
return true;
}
- return getFauxShuffleMask(Op, DemandedElts, Mask, Inputs, DAG, Depth,
- ResolveZero);
+ if (getFauxShuffleMask(Op, DemandedElts, Mask, Inputs, DAG, Depth,
+ ResolveZero)) {
+ KnownUndef = KnownZero = APInt::getNullValue(Mask.size());
+ for (int i = 0, e = Mask.size(); i != e; ++i) {
+ int M = Mask[i];
+ if (SM_SentinelUndef == M)
+ KnownUndef.setBit(i);
+ if (SM_SentinelZero == M)
+ KnownZero.setBit(i);
+ }
+ return true;
+ }
+ return false;
}
static bool getTargetShuffleInputs(SDValue Op, SmallVectorImpl<SDValue> &Inputs,
@@ -7279,10 +7290,11 @@ static bool getTargetShuffleInputs(SDVal
if (!VT.isSimple() || !VT.isVector())
return false;
+ APInt KnownUndef, KnownZero;
unsigned NumElts = Op.getValueType().getVectorNumElements();
APInt DemandedElts = APInt::getAllOnesValue(NumElts);
- return getTargetShuffleInputs(Op, DemandedElts, Inputs, Mask, DAG, Depth,
- ResolveZero);
+ return getTargetShuffleInputs(Op, DemandedElts, Inputs, Mask, KnownUndef,
+ KnownZero, DAG, Depth, ResolveZero);
}
/// Returns the scalar element that will make up the ith
@@ -34572,10 +34584,11 @@ bool X86TargetLowering::SimplifyDemanded
}
// Get target/faux shuffle mask.
+ APInt OpUndef, OpZero;
SmallVector<int, 64> OpMask;
SmallVector<SDValue, 2> OpInputs;
- if (!getTargetShuffleInputs(Op, DemandedElts, OpInputs, OpMask, TLO.DAG,
- Depth, false))
+ if (!getTargetShuffleInputs(Op, DemandedElts, OpInputs, OpMask, OpUndef,
+ OpZero, TLO.DAG, Depth, false))
return false;
// Shuffle inputs must be the same size as the result.
@@ -34586,19 +34599,14 @@ bool X86TargetLowering::SimplifyDemanded
}))
return false;
- // Clear known elts that might have been set above.
- KnownZero.clearAllBits();
- KnownUndef.clearAllBits();
+ KnownZero = OpZero;
+ KnownUndef = OpUndef;
// Check if shuffle mask can be simplified to undef/zero/identity.
int NumSrcs = OpInputs.size();
- for (int i = 0; i != NumElts; ++i) {
- int &M = OpMask[i];
+ for (int i = 0; i != NumElts; ++i)
if (!DemandedElts[i])
- M = SM_SentinelUndef;
- else if (0 <= M && OpInputs[M / NumElts].isUndef())
- M = SM_SentinelUndef;
- }
+ OpMask[i] = SM_SentinelUndef;
if (isUndefInRange(OpMask, 0, NumElts)) {
KnownUndef.setAllBits();
@@ -34628,21 +34636,13 @@ bool X86TargetLowering::SimplifyDemanded
SrcElts.setBit(M);
}
+ // TODO - Propagate input undef/zero elts.
APInt SrcUndef, SrcZero;
if (SimplifyDemandedVectorElts(OpInputs[Src], SrcElts, SrcUndef, SrcZero,
TLO, Depth + 1))
return true;
}
- // Extract known zero/undef elements.
- // TODO - Propagate input undef/zero elts.
- for (int i = 0; i != NumElts; ++i) {
- if (OpMask[i] == SM_SentinelUndef)
- KnownUndef.setBit(i);
- if (OpMask[i] == SM_SentinelZero)
- KnownZero.setBit(i);
- }
-
return false;
}
More information about the llvm-commits
mailing list