Skip to content

Commit 8be1d12

Browse files
committed
[X86] combineX86ShufflesRecursively/combineX86ShuffleChain - pass down SDLoc instead of relying on Root node every recursion. NFC.
Don't reconstruct the SDLoc every recursion during shuffle combining. Noticed while investigating how to reduce the dependency on the Root node.
1 parent c56514f commit 8be1d12

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39642,19 +39642,15 @@ static SDValue combineX86ShuffleChainWithExtract(
3964239642
/// into either a single instruction if there is a special purpose instruction
3964339643
/// for this operation, or into a PSHUFB instruction which is a fully general
3964439644
/// instruction but should only be used to replace chains over a certain depth.
39645-
static SDValue combineX86ShuffleChain(ArrayRef<SDValue> Inputs, SDValue Root,
39646-
ArrayRef<int> BaseMask, int Depth,
39647-
ArrayRef<const SDNode *> SrcNodes,
39648-
bool AllowVariableCrossLaneMask,
39649-
bool AllowVariablePerLaneMask,
39650-
bool IsMaskedShuffle,
39651-
SelectionDAG &DAG,
39652-
const X86Subtarget &Subtarget) {
39645+
static SDValue combineX86ShuffleChain(
39646+
ArrayRef<SDValue> Inputs, SDValue Root, ArrayRef<int> BaseMask, int Depth,
39647+
ArrayRef<const SDNode *> SrcNodes, bool AllowVariableCrossLaneMask,
39648+
bool AllowVariablePerLaneMask, bool IsMaskedShuffle, SelectionDAG &DAG,
39649+
const SDLoc &DL, const X86Subtarget &Subtarget) {
3965339650
assert(!BaseMask.empty() && "Cannot combine an empty shuffle mask!");
3965439651
assert((Inputs.size() == 1 || Inputs.size() == 2) &&
3965539652
"Unexpected number of shuffle inputs!");
3965639653

39657-
SDLoc DL(Root);
3965839654
unsigned RootOpc = Root.getOpcode();
3965939655
MVT RootVT = Root.getSimpleValueType();
3966039656
unsigned RootSizeInBits = RootVT.getSizeInBits();
@@ -40525,7 +40521,7 @@ static SDValue combineX86ShuffleChainWithExtract(
4052540521
if (SDValue WideShuffle = combineX86ShuffleChain(
4052640522
WideInputs, WideRoot, WideMask, Depth, SrcNodes,
4052740523
AllowVariableCrossLaneMask, AllowVariablePerLaneMask, IsMaskedShuffle,
40528-
DAG, Subtarget)) {
40524+
DAG, SDLoc(WideRoot), Subtarget)) {
4052940525
WideShuffle =
4053040526
extractSubVector(WideShuffle, 0, DAG, SDLoc(Root), RootSizeInBits);
4053140527
return DAG.getBitcast(RootVT, WideShuffle);
@@ -40874,15 +40870,14 @@ static SDValue combineX86ShufflesRecursively(
4087440870
ArrayRef<SDValue> SrcOps, int SrcOpIndex, SDValue Root,
4087540871
ArrayRef<int> RootMask, ArrayRef<const SDNode *> SrcNodes, unsigned Depth,
4087640872
unsigned MaxDepth, bool AllowVariableCrossLaneMask,
40877-
bool AllowVariablePerLaneMask, SelectionDAG &DAG,
40873+
bool AllowVariablePerLaneMask, SelectionDAG &DAG, const SDLoc &DL,
4087840874
const X86Subtarget &Subtarget) {
4087940875
assert(!RootMask.empty() &&
4088040876
(RootMask.size() > 1 || (RootMask[0] == 0 && SrcOpIndex == 0)) &&
4088140877
"Illegal shuffle root mask");
4088240878
MVT RootVT = Root.getSimpleValueType();
4088340879
assert(RootVT.isVector() && "Shuffles operate on vector types!");
4088440880
unsigned RootSizeInBits = RootVT.getSizeInBits();
40885-
SDLoc DL(Root);
4088640881

4088740882
// Bound the depth of our recursive combine because this is ultimately
4088840883
// quadratic in nature.
@@ -41176,7 +41171,7 @@ static SDValue combineX86ShufflesRecursively(
4117641171
}
4117741172
if (SDValue Res = combineX86ShufflesRecursively(
4117841173
Ops, i, Root, ResolvedMask, CombinedNodes, Depth + 1, MaxDepth,
41179-
AllowCrossLaneVar, AllowPerLaneVar, DAG, Subtarget))
41174+
AllowCrossLaneVar, AllowPerLaneVar, DAG, DL, Subtarget))
4118041175
return Res;
4118141176
}
4118241177
}
@@ -41296,7 +41291,7 @@ static SDValue combineX86ShufflesRecursively(
4129641291
// Try to combine into a single shuffle instruction.
4129741292
if (SDValue Shuffle = combineX86ShuffleChain(
4129841293
Ops, Root, Mask, Depth, CombinedNodes, AllowVariableCrossLaneMask,
41299-
AllowVariablePerLaneMask, IsMaskedShuffle, DAG, Subtarget))
41294+
AllowVariablePerLaneMask, IsMaskedShuffle, DAG, DL, Subtarget))
4130041295
return Shuffle;
4130141296

4130241297
// If all the operands come from the same larger vector, fallthrough and try
@@ -41324,7 +41319,7 @@ static SDValue combineX86ShufflesRecursively(SDValue Op, SelectionDAG &DAG,
4132441319
return combineX86ShufflesRecursively(
4132541320
{Op}, 0, Op, {0}, {}, /*Depth*/ 0, X86::MaxShuffleCombineDepth,
4132641321
/*AllowCrossLaneVarMask*/ true, /*AllowPerLaneVarMask*/ true, DAG,
41327-
Subtarget);
41322+
SDLoc(Op), Subtarget);
4132841323
}
4132941324

4133041325
/// Get the PSHUF-style mask from PSHUF node.
@@ -41977,7 +41972,7 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
4197741972
{BC}, 0, BC, DemandedMask, {}, /*Depth*/ 0,
4197841973
X86::MaxShuffleCombineDepth,
4197941974
/*AllowCrossLaneVarMask*/ true,
41980-
/*AllowPerLaneVarMask*/ true, DAG, Subtarget))
41975+
/*AllowPerLaneVarMask*/ true, DAG, DL, Subtarget))
4198141976
return DAG.getNode(X86ISD::VBROADCAST, DL, VT,
4198241977
DAG.getBitcast(SrcVT, Res));
4198341978
}
@@ -43980,7 +43975,7 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(
4398043975
SDValue NewShuffle = combineX86ShufflesRecursively(
4398143976
{Op}, 0, Op, DemandedMask, {}, 0, X86::MaxShuffleCombineDepth - Depth,
4398243977
/*AllowCrossLaneVarMask*/ true, /*AllowPerLaneVarMask*/ true, TLO.DAG,
43983-
Subtarget);
43978+
SDLoc(Op), Subtarget);
4398443979
if (NewShuffle)
4398543980
return TLO.CombineTo(Op, NewShuffle);
4398643981
}
@@ -51580,7 +51575,7 @@ static SDValue combineAnd(SDNode *N, SelectionDAG &DAG,
5158051575
{SrcVec}, 0, SrcVec, ShuffleMask, {}, /*Depth*/ 1,
5158151576
X86::MaxShuffleCombineDepth,
5158251577
/*AllowVarCrossLaneMask*/ true,
51583-
/*AllowVarPerLaneMask*/ true, DAG, Subtarget))
51578+
/*AllowVarPerLaneMask*/ true, DAG, SDLoc(SrcVec), Subtarget))
5158451579
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, VT, Shuffle,
5158551580
N0.getOperand(1));
5158651581
}

0 commit comments

Comments
 (0)