Skip to content

Commit 0ff13f7

Browse files
committed
[X86] combineX86ShufflesConstants - replace Root argument with VT/DL arguments.
combineX86ShufflesConstants doesn't need to know specifically about the Root node, it just needs the type + SDLoc. Minor tweak to make it easier to reuse this function in places other than recursive shuffle combining.
1 parent e980990 commit 0ff13f7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39554,13 +39554,11 @@ static SDValue canonicalizeShuffleMaskWithHorizOp(
3955439554
// Attempt to constant fold all of the constant source ops.
3955539555
// Returns true if the entire shuffle is folded to a constant.
3955639556
// TODO: Extend this to merge multiple constant Ops and update the mask.
39557-
static SDValue combineX86ShufflesConstants(ArrayRef<SDValue> Ops,
39558-
ArrayRef<int> Mask, SDValue Root,
39557+
static SDValue combineX86ShufflesConstants(MVT VT, ArrayRef<SDValue> Ops,
39558+
ArrayRef<int> Mask,
3955939559
bool HasVariableMask,
39560-
SelectionDAG &DAG,
39560+
SelectionDAG &DAG, const SDLoc &DL,
3956139561
const X86Subtarget &Subtarget) {
39562-
MVT VT = Root.getSimpleValueType();
39563-
3956439562
unsigned SizeInBits = VT.getSizeInBits();
3956539563
unsigned NumMaskElts = Mask.size();
3956639564
unsigned MaskSizeInBits = SizeInBits / NumMaskElts;
@@ -39585,7 +39583,6 @@ static SDValue combineX86ShufflesConstants(ArrayRef<SDValue> Ops,
3958539583
return SDValue();
3958639584

3958739585
// Shuffle the constant bits according to the mask.
39588-
SDLoc DL(Root);
3958939586
APInt UndefElts(NumMaskElts, 0);
3959039587
APInt ZeroElts(NumMaskElts, 0);
3959139588
APInt ConstantElts(NumMaskElts, 0);
@@ -39625,7 +39622,7 @@ static SDValue combineX86ShufflesConstants(ArrayRef<SDValue> Ops,
3962539622

3962639623
// Attempt to create a zero vector.
3962739624
if ((UndefElts | ZeroElts).isAllOnes())
39628-
return getZeroVector(Root.getSimpleValueType(), Subtarget, DAG, DL);
39625+
return getZeroVector(VT, Subtarget, DAG, DL);
3962939626

3963039627
// Create the constant data.
3963139628
MVT MaskSVT;
@@ -39691,6 +39688,7 @@ static SDValue combineX86ShufflesRecursively(
3969139688
MVT RootVT = Root.getSimpleValueType();
3969239689
assert(RootVT.isVector() && "Shuffles operate on vector types!");
3969339690
unsigned RootSizeInBits = RootVT.getSizeInBits();
39691+
SDLoc DL(Root);
3969439692

3969539693
// Bound the depth of our recursive combine because this is ultimately
3969639694
// quadratic in nature.
@@ -39946,10 +39944,10 @@ static SDValue combineX86ShufflesRecursively(
3994639944
if (all_of(Mask, [](int Idx) { return Idx == SM_SentinelUndef; }))
3994739945
return DAG.getUNDEF(RootVT);
3994839946
if (all_of(Mask, [](int Idx) { return Idx < 0; }))
39949-
return getZeroVector(RootVT, Subtarget, DAG, SDLoc(Root));
39947+
return getZeroVector(RootVT, Subtarget, DAG, DL);
3995039948
if (Ops.size() == 1 && ISD::isBuildVectorAllOnes(Ops[0].getNode()) &&
3995139949
!llvm::is_contained(Mask, SM_SentinelZero))
39952-
return getOnesVector(RootVT, DAG, SDLoc(Root));
39950+
return getOnesVector(RootVT, DAG, DL);
3995339951

3995439952
assert(!Ops.empty() && "Shuffle with no inputs detected");
3995539953
HasVariableMask |= IsOpVariableMask;
@@ -39990,7 +39988,7 @@ static SDValue combineX86ShufflesRecursively(
3999039988

3999139989
// Attempt to constant fold all of the constant source ops.
3999239990
if (SDValue Cst = combineX86ShufflesConstants(
39993-
Ops, Mask, Root, HasVariableMask, DAG, Subtarget))
39991+
RootVT, Ops, Mask, HasVariableMask, DAG, DL, Subtarget))
3999439992
return Cst;
3999539993

3999639994
// If constant fold failed and we only have constants - then we have
@@ -40010,7 +40008,7 @@ static SDValue combineX86ShufflesRecursively(
4001040008
// Canonicalize the combined shuffle mask chain with horizontal ops.
4001140009
// NOTE: This will update the Ops and Mask.
4001240010
if (SDValue HOp = canonicalizeShuffleMaskWithHorizOp(
40013-
Ops, Mask, RootSizeInBits, SDLoc(Root), DAG, Subtarget))
40011+
Ops, Mask, RootSizeInBits, DL, DAG, Subtarget))
4001440012
return DAG.getBitcast(RootVT, HOp);
4001540013

4001640014
// Try to refine our inputs given our knowledge of target shuffle mask.

0 commit comments

Comments
 (0)