Skip to content

Commit 00262ab

Browse files
committed
[X86] Pull out repeated SDLoc in various ADD/SUB/XOR folds. NFC.
1 parent 424188a commit 00262ab

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50184,12 +50184,12 @@ static SDValue combineAddOrSubToADCOrSBB(bool IsSub, const SDLoc &DL, EVT VT,
5018450184
/// If this is an add or subtract where one operand is produced by a cmp+setcc,
5018550185
/// then try to convert it to an ADC or SBB. This replaces TEST+SET+{ADD/SUB}
5018650186
/// with CMP+{ADC, SBB}.
50187-
static SDValue combineAddOrSubToADCOrSBB(SDNode *N, SelectionDAG &DAG) {
50187+
static SDValue combineAddOrSubToADCOrSBB(SDNode *N, const SDLoc &DL,
50188+
SelectionDAG &DAG) {
5018850189
bool IsSub = N->getOpcode() == ISD::SUB;
5018950190
SDValue X = N->getOperand(0);
5019050191
SDValue Y = N->getOperand(1);
5019150192
EVT VT = N->getValueType(0);
50192-
SDLoc DL(N);
5019350193

5019450194
if (SDValue ADCOrSBB = combineAddOrSubToADCOrSBB(IsSub, DL, VT, X, Y, DAG))
5019550195
return ADCOrSBB;
@@ -52718,7 +52718,7 @@ static SDValue foldXor1SetCC(SDNode *N, SelectionDAG &DAG) {
5271852718
return getSETCC(NewCC, LHS->getOperand(1), DL, DAG);
5271952719
}
5272052720

52721-
static SDValue combineXorSubCTLZ(SDNode *N, SelectionDAG &DAG,
52721+
static SDValue combineXorSubCTLZ(SDNode *N, const SDLoc &DL, SelectionDAG &DAG,
5272252722
const X86Subtarget &Subtarget) {
5272352723
assert((N->getOpcode() == ISD::XOR || N->getOpcode() == ISD::SUB) &&
5272452724
"Invalid opcode for combing with CTLZ");
@@ -52758,7 +52758,6 @@ static SDValue combineXorSubCTLZ(SDNode *N, SelectionDAG &DAG,
5275852758

5275952759
if (C->getZExtValue() != uint64_t(OpCTLZ.getValueSizeInBits() - 1))
5276052760
return SDValue();
52761-
SDLoc DL(N);
5276252761
EVT OpVT = VT;
5276352762
SDValue Op = OpCTLZ.getOperand(0);
5276452763
if (VT == MVT::i8) {
@@ -52781,11 +52780,12 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5278152780
SDValue N0 = N->getOperand(0);
5278252781
SDValue N1 = N->getOperand(1);
5278352782
EVT VT = N->getValueType(0);
52783+
SDLoc DL(N);
5278452784

5278552785
// If this is SSE1 only convert to FXOR to avoid scalarization.
5278652786
if (Subtarget.hasSSE1() && !Subtarget.hasSSE2() && VT == MVT::v4i32) {
5278752787
return DAG.getBitcast(MVT::v4i32,
52788-
DAG.getNode(X86ISD::FXOR, SDLoc(N), MVT::v4f32,
52788+
DAG.getNode(X86ISD::FXOR, DL, MVT::v4f32,
5278952789
DAG.getBitcast(MVT::v4f32, N0),
5279052790
DAG.getBitcast(MVT::v4f32, N1)));
5279152791
}
@@ -52805,7 +52805,7 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5280552805
if (SDValue FPLogic = convertIntLogicToFPLogic(N, DAG, DCI, Subtarget))
5280652806
return FPLogic;
5280752807

52808-
if (SDValue R = combineXorSubCTLZ(N, DAG, Subtarget))
52808+
if (SDValue R = combineXorSubCTLZ(N, DL, DAG, Subtarget))
5280952809
return R;
5281052810

5281152811
if (DCI.isBeforeLegalizeOps())
@@ -52826,8 +52826,8 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5282652826
N0.getOperand(0).getValueType().isVector() &&
5282752827
N0.getOperand(0).getValueType().getVectorElementType() == MVT::i1 &&
5282852828
TLI.isTypeLegal(N0.getOperand(0).getValueType()) && N0.hasOneUse()) {
52829-
return DAG.getBitcast(VT, DAG.getNOT(SDLoc(N), N0.getOperand(0),
52830-
N0.getOperand(0).getValueType()));
52829+
return DAG.getBitcast(
52830+
VT, DAG.getNOT(DL, N0.getOperand(0), N0.getOperand(0).getValueType()));
5283152831
}
5283252832

5283352833
// Handle AVX512 mask widening.
@@ -52837,8 +52837,8 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5283752837
N0.getOpcode() == ISD::INSERT_SUBVECTOR && N0.getOperand(0).isUndef() &&
5283852838
TLI.isTypeLegal(N0.getOperand(1).getValueType())) {
5283952839
return DAG.getNode(
52840-
ISD::INSERT_SUBVECTOR, SDLoc(N), VT, N0.getOperand(0),
52841-
DAG.getNOT(SDLoc(N), N0.getOperand(1), N0.getOperand(1).getValueType()),
52840+
ISD::INSERT_SUBVECTOR, DL, VT, N0.getOperand(0),
52841+
DAG.getNOT(DL, N0.getOperand(1), N0.getOperand(1).getValueType()),
5284252842
N0.getOperand(2));
5284352843
}
5284452844

@@ -52851,7 +52851,6 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
5285152851
auto *N1C = dyn_cast<ConstantSDNode>(N1);
5285252852
auto *N001C = dyn_cast<ConstantSDNode>(TruncExtSrc.getOperand(1));
5285352853
if (N1C && !N1C->isOpaque() && N001C && !N001C->isOpaque()) {
52854-
SDLoc DL(N);
5285552854
SDValue LHS = DAG.getZExtOrTrunc(TruncExtSrc.getOperand(0), DL, VT);
5285652855
SDValue RHS = DAG.getZExtOrTrunc(TruncExtSrc.getOperand(1), DL, VT);
5285752856
return DAG.getNode(ISD::XOR, DL, VT, LHS,
@@ -55419,7 +55418,8 @@ static SDValue combineAddOfPMADDWD(SelectionDAG &DAG, SDValue N0, SDValue N1,
5541955418
/// Try to fold those constants into an 'add' instruction to reduce instruction
5542055419
/// count. We do this with CMOV rather the generic 'select' because there are
5542155420
/// earlier folds that may be used to turn select-of-constants into logic hacks.
55422-
static SDValue pushAddIntoCmovOfConsts(SDNode *N, SelectionDAG &DAG,
55421+
static SDValue pushAddIntoCmovOfConsts(SDNode *N, const SDLoc &DL,
55422+
SelectionDAG &DAG,
5542355423
const X86Subtarget &Subtarget) {
5542455424
// If an operand is zero, add-of-0 gets simplified away, so that's clearly
5542555425
// better because we eliminate 1-2 instructions. This transform is still
@@ -55451,7 +55451,6 @@ static SDValue pushAddIntoCmovOfConsts(SDNode *N, SelectionDAG &DAG,
5545155451
return SDValue();
5545255452

5545355453
EVT VT = N->getValueType(0);
55454-
SDLoc DL(N);
5545555454
SDValue FalseOp = Cmov.getOperand(0);
5545655455
SDValue TrueOp = Cmov.getOperand(1);
5545755456

@@ -55492,7 +55491,7 @@ static SDValue combineAdd(SDNode *N, SelectionDAG &DAG,
5549255491
SDValue Op1 = N->getOperand(1);
5549355492
SDLoc DL(N);
5549455493

55495-
if (SDValue Select = pushAddIntoCmovOfConsts(N, DAG, Subtarget))
55494+
if (SDValue Select = pushAddIntoCmovOfConsts(N, DL, DAG, Subtarget))
5549655495
return Select;
5549755496

5549855497
if (SDValue MAdd = matchPMADDWD(DAG, Op0, Op1, DL, VT, Subtarget))
@@ -55550,7 +55549,7 @@ static SDValue combineAdd(SDNode *N, SelectionDAG &DAG,
5555055549
Op0.getOperand(0), Op0.getOperand(2));
5555155550
}
5555255551

55553-
return combineAddOrSubToADCOrSBB(N, DAG);
55552+
return combineAddOrSubToADCOrSBB(N, DL, DAG);
5555455553
}
5555555554

5555655555
// Try to fold (sub Y, cmovns X, -X) -> (add Y, cmovns -X, X) if the cmov
@@ -55626,6 +55625,7 @@ static SDValue combineSub(SDNode *N, SelectionDAG &DAG,
5562655625
const X86Subtarget &Subtarget) {
5562755626
SDValue Op0 = N->getOperand(0);
5562855627
SDValue Op1 = N->getOperand(1);
55628+
SDLoc DL(N);
5562955629

5563055630
// TODO: Add NoOpaque handling to isConstantIntBuildVectorOrConstantInt.
5563155631
auto IsNonOpaqueConstant = [&](SDValue Op) {
@@ -55645,7 +55645,6 @@ static SDValue combineSub(SDNode *N, SelectionDAG &DAG,
5564555645
if (Op1.getOpcode() == ISD::XOR && IsNonOpaqueConstant(Op0) &&
5564655646
!isNullConstant(Op0) && IsNonOpaqueConstant(Op1.getOperand(1)) &&
5564755647
Op1->hasOneUse()) {
55648-
SDLoc DL(N);
5564955648
EVT VT = Op0.getValueType();
5565055649
SDValue NewXor = DAG.getNode(ISD::XOR, SDLoc(Op1), VT, Op1.getOperand(0),
5565155650
DAG.getNOT(SDLoc(Op1), Op1.getOperand(1), VT));
@@ -55676,14 +55675,14 @@ static SDValue combineSub(SDNode *N, SelectionDAG &DAG,
5567655675
assert(!Op1->hasAnyUseOfValue(1) && "Overflow bit in use");
5567755676
SDValue ADC = DAG.getNode(X86ISD::ADC, SDLoc(Op1), Op1->getVTList(), Op0,
5567855677
Op1.getOperand(1), Op1.getOperand(2));
55679-
return DAG.getNode(ISD::SUB, SDLoc(N), Op0.getValueType(), ADC.getValue(0),
55678+
return DAG.getNode(ISD::SUB, DL, Op0.getValueType(), ADC.getValue(0),
5568055679
Op1.getOperand(0));
5568155680
}
5568255681

55683-
if (SDValue V = combineXorSubCTLZ(N, DAG, Subtarget))
55682+
if (SDValue V = combineXorSubCTLZ(N, DL, DAG, Subtarget))
5568455683
return V;
5568555684

55686-
if (SDValue V = combineAddOrSubToADCOrSBB(N, DAG))
55685+
if (SDValue V = combineAddOrSubToADCOrSBB(N, DL, DAG))
5568755686
return V;
5568855687

5568955688
return combineSubSetcc(N, DAG);

0 commit comments

Comments
 (0)