Skip to content

Commit 066dc1e

Browse files
committed
[X86] combineMulToPMADDWD/combineMulToPMULDQ/reduceVMULWidth - pull out repeated SDLoc(). NFC.
1 parent 3fca9d7 commit 066dc1e

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46875,7 +46875,7 @@ static bool canReduceVMulWidth(SDNode *N, SelectionDAG &DAG, ShrinkMode &Mode) {
4687546875
/// If %2 == zext32(trunc16(%2)), i.e., the scalar value range of %2 is
4687646876
/// 0 to 65535, and the scalar value range of %4 is also 0 to 65535,
4687746877
/// generate pmullw+pmulhuw for it (MULU16 mode).
46878-
static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
46878+
static SDValue reduceVMULWidth(SDNode *N, const SDLoc &DL, SelectionDAG &DAG,
4687946879
const X86Subtarget &Subtarget) {
4688046880
// Check for legality
4688146881
// pmullw/pmulhw are not supported by SSE.
@@ -46894,7 +46894,6 @@ static SDValue reduceVMULWidth(SDNode *N, SelectionDAG &DAG,
4689446894
if (!canReduceVMulWidth(N, DAG, Mode))
4689546895
return SDValue();
4689646896

46897-
SDLoc DL(N);
4689846897
SDValue N0 = N->getOperand(0);
4689946898
SDValue N1 = N->getOperand(1);
4690046899
EVT VT = N->getOperand(0).getValueType();
@@ -47034,7 +47033,8 @@ static SDValue combineMulSpecial(uint64_t MulAmt, SDNode *N, SelectionDAG &DAG,
4703447033
// If the upper 17 bits of either element are zero and the other element are
4703547034
// zero/sign bits then we can use PMADDWD, which is always at least as quick as
4703647035
// PMULLD, except on KNL.
47037-
static SDValue combineMulToPMADDWD(SDNode *N, SelectionDAG &DAG,
47036+
static SDValue combineMulToPMADDWD(SDNode *N, const SDLoc &DL,
47037+
SelectionDAG &DAG,
4703847038
const X86Subtarget &Subtarget) {
4703947039
if (!Subtarget.hasSSE2())
4704047040
return SDValue();
@@ -47096,32 +47096,31 @@ static SDValue combineMulToPMADDWD(SDNode *N, SelectionDAG &DAG,
4709647096
return Op;
4709747097
// Mask off upper 16-bits of sign-extended constants.
4709847098
if (ISD::isBuildVectorOfConstantSDNodes(Op.getNode()))
47099-
return DAG.getNode(ISD::AND, SDLoc(N), VT, Op,
47100-
DAG.getConstant(0xFFFF, SDLoc(N), VT));
47099+
return DAG.getNode(ISD::AND, DL, VT, Op, DAG.getConstant(0xFFFF, DL, VT));
4710147100
if (Op.getOpcode() == ISD::SIGN_EXTEND && N->isOnlyUserOf(Op.getNode())) {
4710247101
SDValue Src = Op.getOperand(0);
4710347102
// Convert sext(vXi16) to zext(vXi16).
4710447103
if (Src.getScalarValueSizeInBits() == 16 && VT.getSizeInBits() <= 128)
47105-
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, Src);
47104+
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Src);
4710647105
// Convert sext(vXi8) to zext(vXi16 sext(vXi8)) on pre-SSE41 targets
4710747106
// which will expand the extension.
4710847107
if (Src.getScalarValueSizeInBits() < 16 && !Subtarget.hasSSE41()) {
4710947108
EVT ExtVT = VT.changeVectorElementType(MVT::i16);
47110-
Src = DAG.getNode(ISD::SIGN_EXTEND, SDLoc(N), ExtVT, Src);
47111-
return DAG.getNode(ISD::ZERO_EXTEND, SDLoc(N), VT, Src);
47109+
Src = DAG.getNode(ISD::SIGN_EXTEND, DL, ExtVT, Src);
47110+
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Src);
4711247111
}
4711347112
}
4711447113
// Convert SIGN_EXTEND_VECTOR_INREG to ZEXT_EXTEND_VECTOR_INREG.
4711547114
if (Op.getOpcode() == ISD::SIGN_EXTEND_VECTOR_INREG &&
4711647115
N->isOnlyUserOf(Op.getNode())) {
4711747116
SDValue Src = Op.getOperand(0);
4711847117
if (Src.getScalarValueSizeInBits() == 16)
47119-
return DAG.getNode(ISD::ZERO_EXTEND_VECTOR_INREG, SDLoc(N), VT, Src);
47118+
return DAG.getNode(ISD::ZERO_EXTEND_VECTOR_INREG, DL, VT, Src);
4712047119
}
4712147120
// Convert VSRAI(Op, 16) to VSRLI(Op, 16).
4712247121
if (Op.getOpcode() == X86ISD::VSRAI && Op.getConstantOperandVal(1) == 16 &&
4712347122
N->isOnlyUserOf(Op.getNode())) {
47124-
return DAG.getNode(X86ISD::VSRLI, SDLoc(N), VT, Op.getOperand(0),
47123+
return DAG.getNode(X86ISD::VSRLI, DL, VT, Op.getOperand(0),
4712547124
Op.getOperand(1));
4712647125
}
4712747126
return SDValue();
@@ -47142,11 +47141,10 @@ static SDValue combineMulToPMADDWD(SDNode *N, SelectionDAG &DAG,
4714247141
DAG.getBitcast(OpVT, Ops[0]),
4714347142
DAG.getBitcast(OpVT, Ops[1]));
4714447143
};
47145-
return SplitOpsAndApply(DAG, Subtarget, SDLoc(N), VT, {N0, N1},
47146-
PMADDWDBuilder);
47144+
return SplitOpsAndApply(DAG, Subtarget, DL, VT, {N0, N1}, PMADDWDBuilder);
4714747145
}
4714847146

47149-
static SDValue combineMulToPMULDQ(SDNode *N, SelectionDAG &DAG,
47147+
static SDValue combineMulToPMULDQ(SDNode *N, const SDLoc &DL, SelectionDAG &DAG,
4715047148
const X86Subtarget &Subtarget) {
4715147149
if (!Subtarget.hasSSE2())
4715247150
return SDValue();
@@ -47170,8 +47168,8 @@ static SDValue combineMulToPMULDQ(SDNode *N, SelectionDAG &DAG,
4717047168
ArrayRef<SDValue> Ops) {
4717147169
return DAG.getNode(X86ISD::PMULDQ, DL, Ops[0].getValueType(), Ops);
4717247170
};
47173-
return SplitOpsAndApply(DAG, Subtarget, SDLoc(N), VT, { N0, N1 },
47174-
PMULDQBuilder, /*CheckBWI*/false);
47171+
return SplitOpsAndApply(DAG, Subtarget, DL, VT, {N0, N1}, PMULDQBuilder,
47172+
/*CheckBWI*/ false);
4717547173
}
4717647174

4717747175
// If the upper bits are zero we can use a single pmuludq.
@@ -47181,8 +47179,8 @@ static SDValue combineMulToPMULDQ(SDNode *N, SelectionDAG &DAG,
4718147179
ArrayRef<SDValue> Ops) {
4718247180
return DAG.getNode(X86ISD::PMULUDQ, DL, Ops[0].getValueType(), Ops);
4718347181
};
47184-
return SplitOpsAndApply(DAG, Subtarget, SDLoc(N), VT, { N0, N1 },
47185-
PMULUDQBuilder, /*CheckBWI*/false);
47182+
return SplitOpsAndApply(DAG, Subtarget, DL, VT, {N0, N1}, PMULUDQBuilder,
47183+
/*CheckBWI*/ false);
4718647184
}
4718747185

4718847186
return SDValue();
@@ -47192,15 +47190,16 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
4719247190
TargetLowering::DAGCombinerInfo &DCI,
4719347191
const X86Subtarget &Subtarget) {
4719447192
EVT VT = N->getValueType(0);
47193+
SDLoc DL(N);
4719547194

47196-
if (SDValue V = combineMulToPMADDWD(N, DAG, Subtarget))
47195+
if (SDValue V = combineMulToPMADDWD(N, DL, DAG, Subtarget))
4719747196
return V;
4719847197

47199-
if (SDValue V = combineMulToPMULDQ(N, DAG, Subtarget))
47198+
if (SDValue V = combineMulToPMULDQ(N, DL, DAG, Subtarget))
4720047199
return V;
4720147200

4720247201
if (DCI.isBeforeLegalize() && VT.isVector())
47203-
return reduceVMULWidth(N, DAG, Subtarget);
47202+
return reduceVMULWidth(N, DL, DAG, Subtarget);
4720447203

4720547204
// Optimize a single multiply with constant into two operations in order to
4720647205
// implement it with two cheaper instructions, e.g. LEA + SHL, LEA + LEA.
@@ -47240,7 +47239,6 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
4724047239
assert(SignMulAmt != INT64_MIN && "Int min should have been handled!");
4724147240
uint64_t AbsMulAmt = SignMulAmt < 0 ? -SignMulAmt : SignMulAmt;
4724247241

47243-
SDLoc DL(N);
4724447242
SDValue NewMul = SDValue();
4724547243
if (VT == MVT::i64 || VT == MVT::i32) {
4724647244
if (AbsMulAmt == 3 || AbsMulAmt == 5 || AbsMulAmt == 9) {

0 commit comments

Comments
 (0)