[llvm] r373868 - [X86][SSE] Remove resolveTargetShuffleInputs and use getTargetShuffleInputs directly.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 6 12:07:00 PDT 2019
Author: rksimon
Date: Sun Oct 6 12:07:00 2019
New Revision: 373868
URL: http://llvm.org/viewvc/llvm-project?rev=373868&view=rev
Log:
[X86][SSE] Remove resolveTargetShuffleInputs and use getTargetShuffleInputs directly.
Move the resolveTargetShuffleInputsAndMask call to after the shuffle mask combine before the undef/zero constant fold instead.
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=373868&r1=373867&r2=373868&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Oct 6 12:07:00 2019
@@ -6816,11 +6816,10 @@ static bool getTargetShuffleAndZeroables
// Forward declaration (for getFauxShuffleMask recursive check).
// TODO: Use DemandedElts variant.
-static bool resolveTargetShuffleInputs(SDValue Op,
- SmallVectorImpl<SDValue> &Inputs,
- SmallVectorImpl<int> &Mask,
- SelectionDAG &DAG, unsigned Depth,
- bool ResolveZero);
+static bool getTargetShuffleInputs(SDValue Op, SmallVectorImpl<SDValue> &Inputs,
+ SmallVectorImpl<int> &Mask,
+ SelectionDAG &DAG, unsigned Depth,
+ bool ResolveZero);
// Attempt to decode ops that could be represented as a shuffle mask.
// The decoded shuffle mask may contain a different number of elements to the
@@ -6923,10 +6922,10 @@ static bool getFauxShuffleMask(SDValue N
return false;
SmallVector<int, 64> SrcMask0, SrcMask1;
SmallVector<SDValue, 2> SrcInputs0, SrcInputs1;
- if (!resolveTargetShuffleInputs(N0, SrcInputs0, SrcMask0, DAG, Depth + 1,
- ResolveZero) ||
- !resolveTargetShuffleInputs(N1, SrcInputs1, SrcMask1, DAG, Depth + 1,
- ResolveZero))
+ if (!getTargetShuffleInputs(N0, SrcInputs0, SrcMask0, DAG, Depth + 1,
+ ResolveZero) ||
+ !getTargetShuffleInputs(N1, SrcInputs1, SrcMask1, DAG, Depth + 1,
+ ResolveZero))
return false;
int MaskSize = std::max(SrcMask0.size(), SrcMask1.size());
SmallVector<int, 64> Mask0, Mask1;
@@ -6975,8 +6974,8 @@ static bool getFauxShuffleMask(SDValue N
// Handle INSERT_SUBVECTOR(SRC0, SHUFFLE(SRC1)).
SmallVector<int, 64> SubMask;
SmallVector<SDValue, 2> SubInputs;
- if (!resolveTargetShuffleInputs(peekThroughOneUseBitcasts(Sub), SubInputs,
- SubMask, DAG, Depth + 1, ResolveZero))
+ if (!getTargetShuffleInputs(peekThroughOneUseBitcasts(Sub), SubInputs,
+ SubMask, DAG, Depth + 1, ResolveZero))
return false;
if (SubMask.size() != NumSubElts) {
assert(((SubMask.size() % NumSubElts) == 0 ||
@@ -7277,33 +7276,14 @@ static bool getTargetShuffleInputs(SDVal
ResolveZero);
}
-/// Calls getTargetShuffleInputs to resolve a target shuffle mask's inputs
-/// and set the SM_SentinelUndef and SM_SentinelZero values. Then check the
-/// remaining input indices in case we now have a unary shuffle and adjust the
-/// inputs accordingly.
-/// Returns true if the target shuffle mask was decoded.
-static bool resolveTargetShuffleInputs(SDValue Op, const APInt &DemandedElts,
- SmallVectorImpl<SDValue> &Inputs,
- SmallVectorImpl<int> &Mask,
- SelectionDAG &DAG, unsigned Depth,
- bool ResolveZero) {
- if (!getTargetShuffleInputs(Op, DemandedElts, Inputs, Mask, DAG, Depth,
- ResolveZero))
- return false;
-
- resolveTargetShuffleInputsAndMask(Inputs, Mask);
- return true;
-}
-
-static bool resolveTargetShuffleInputs(SDValue Op,
- SmallVectorImpl<SDValue> &Inputs,
- SmallVectorImpl<int> &Mask,
- SelectionDAG &DAG, unsigned Depth,
- bool ResolveZero = true) {
+static bool getTargetShuffleInputs(SDValue Op, SmallVectorImpl<SDValue> &Inputs,
+ SmallVectorImpl<int> &Mask,
+ SelectionDAG &DAG, unsigned Depth = 0,
+ bool ResolveZero = true) {
unsigned NumElts = Op.getValueType().getVectorNumElements();
APInt DemandedElts = APInt::getAllOnesValue(NumElts);
- return resolveTargetShuffleInputs(Op, DemandedElts, Inputs, Mask, DAG, Depth,
- ResolveZero);
+ return getTargetShuffleInputs(Op, DemandedElts, Inputs, Mask, DAG, Depth,
+ ResolveZero);
}
/// Returns the scalar element that will make up the ith
@@ -33006,7 +32986,7 @@ static SDValue combineX86ShufflesRecursi
// Extract target shuffle mask and resolve sentinels and inputs.
SmallVector<int, 64> OpMask;
SmallVector<SDValue, 2> OpInputs;
- if (!resolveTargetShuffleInputs(Op, OpInputs, OpMask, DAG, Depth))
+ if (!getTargetShuffleInputs(Op, OpInputs, OpMask, DAG, Depth))
return SDValue();
// Add the inputs to the Ops list, avoiding duplicates.
@@ -33109,6 +33089,9 @@ static SDValue combineX86ShufflesRecursi
Mask[i] = OpMaskedIdx;
}
+ // Remove unused/repeated shuffle source ops.
+ resolveTargetShuffleInputsAndMask(Ops, Mask);
+
// Handle the all undef/zero cases early.
if (all_of(Mask, [](int Idx) { return Idx == SM_SentinelUndef; }))
return DAG.getUNDEF(Root.getValueType());
@@ -33120,10 +33103,7 @@ static SDValue combineX86ShufflesRecursi
return getZeroVector(Root.getSimpleValueType(), Subtarget, DAG,
SDLoc(Root));
- // Remove unused/repeated shuffle source ops.
- resolveTargetShuffleInputsAndMask(Ops, Mask);
assert(!Ops.empty() && "Shuffle with no inputs detected");
-
HasVariableMask |= isTargetShuffleVariableMask(Op.getOpcode());
// Update the list of shuffle nodes that have been combined so far.
@@ -34962,7 +34942,7 @@ SDValue X86TargetLowering::SimplifyMulti
SmallVector<int, 16> ShuffleMask;
SmallVector<SDValue, 2> ShuffleOps;
if (VT.isSimple() && VT.isVector() &&
- resolveTargetShuffleInputs(Op, ShuffleOps, ShuffleMask, DAG, Depth)) {
+ getTargetShuffleInputs(Op, ShuffleOps, ShuffleMask, DAG, Depth)) {
// If all the demanded elts are from one operand and are inline,
// then we can use the operand directly.
int NumOps = ShuffleOps.size();
@@ -36041,7 +36021,7 @@ static SDValue combineExtractWithShuffle
// Resolve the target shuffle inputs and mask.
SmallVector<int, 16> Mask;
SmallVector<SDValue, 2> Ops;
- if (!resolveTargetShuffleInputs(SrcBC, Ops, Mask, DAG, 0))
+ if (!getTargetShuffleInputs(SrcBC, Ops, Mask, DAG))
return SDValue();
// Attempt to narrow/widen the shuffle mask to the correct size.
More information about the llvm-commits
mailing list