Skip to content

Commit fe753f7

Browse files
committed
[DAG] visitTRUNCATE - pull out repeated SDLoc(N). NFC.
1 parent d592569 commit fe753f7

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14609,17 +14609,18 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1460914609
EVT VT = N->getValueType(0);
1461014610
EVT SrcVT = N0.getValueType();
1461114611
bool isLE = DAG.getDataLayout().isLittleEndian();
14612+
SDLoc DL(N);
1461214613

1461314614
// trunc(undef) = undef
1461414615
if (N0.isUndef())
1461514616
return DAG.getUNDEF(VT);
1461614617

1461714618
// fold (truncate (truncate x)) -> (truncate x)
1461814619
if (N0.getOpcode() == ISD::TRUNCATE)
14619-
return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0.getOperand(0));
14620+
return DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
1462014621

1462114622
// fold (truncate c1) -> c1
14622-
if (SDValue C = DAG.FoldConstantArithmetic(ISD::TRUNCATE, SDLoc(N), VT, {N0}))
14623+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::TRUNCATE, DL, VT, {N0}))
1462314624
return C;
1462414625

1462514626
// fold (truncate (ext x)) -> (ext x) or (truncate x) or x
@@ -14628,10 +14629,10 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1462814629
N0.getOpcode() == ISD::ANY_EXTEND) {
1462914630
// if the source is smaller than the dest, we still need an extend.
1463014631
if (N0.getOperand(0).getValueType().bitsLT(VT))
14631-
return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, N0.getOperand(0));
14632+
return DAG.getNode(N0.getOpcode(), DL, VT, N0.getOperand(0));
1463214633
// if the source is larger than the dest, than we just need the truncate.
1463314634
if (N0.getOperand(0).getValueType().bitsGT(VT))
14634-
return DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, N0.getOperand(0));
14635+
return DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
1463514636
// if the source and dest are the same type, we can drop both the extend
1463614637
// and the truncate.
1463714638
return N0.getOperand(0);
@@ -14645,8 +14646,8 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1464514646
SDValue ExtVal = N0.getOperand(1);
1464614647
EVT ExtVT = cast<VTSDNode>(ExtVal)->getVT();
1464714648
if (ExtVT.bitsLT(VT) && TLI.preferSextInRegOfTruncate(VT, SrcVT, ExtVT)) {
14648-
SDValue TrX = DAG.getNode(ISD::TRUNCATE, SDLoc(N), VT, X);
14649-
return DAG.getNode(ISD::SIGN_EXTEND_INREG, SDLoc(N), VT, TrX, ExtVal);
14649+
SDValue TrX = DAG.getNode(ISD::TRUNCATE, DL, VT, X);
14650+
return DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, VT, TrX, ExtVal);
1465014651
}
1465114652
}
1465214653

@@ -14681,8 +14682,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1468114682
if (isa<ConstantSDNode>(EltNo) && isTypeLegal(NVT)) {
1468214683
int Elt = EltNo->getAsZExtVal();
1468314684
int Index = isLE ? (Elt*SizeRatio) : (Elt*SizeRatio + (SizeRatio-1));
14684-
14685-
SDLoc DL(N);
1468614685
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, TrTy,
1468714686
DAG.getBitcast(NVT, N0.getOperand(0)),
1468814687
DAG.getVectorIdxConstant(Index, DL));
@@ -14697,7 +14696,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1469714696
SDValue Cond = N0.getOperand(0);
1469814697
SDValue TruncOp0 = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(1));
1469914698
SDValue TruncOp1 = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(2));
14700-
return DAG.getNode(ISD::SELECT, SDLoc(N), VT, Cond, TruncOp0, TruncOp1);
14699+
return DAG.getNode(ISD::SELECT, DL, VT, Cond, TruncOp0, TruncOp1);
1470114700
}
1470214701
}
1470314702

@@ -14709,15 +14708,13 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1470914708
KnownBits Known = DAG.computeKnownBits(Amt);
1471014709
unsigned Size = VT.getScalarSizeInBits();
1471114710
if (Known.countMaxActiveBits() <= Log2_32(Size)) {
14712-
SDLoc SL(N);
1471314711
EVT AmtVT = TLI.getShiftAmountTy(VT, DAG.getDataLayout());
14714-
14715-
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, SL, VT, N0.getOperand(0));
14712+
SDValue Trunc = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
1471614713
if (AmtVT != Amt.getValueType()) {
14717-
Amt = DAG.getZExtOrTrunc(Amt, SL, AmtVT);
14714+
Amt = DAG.getZExtOrTrunc(Amt, DL, AmtVT);
1471814715
AddToWorklist(Amt.getNode());
1471914716
}
14720-
return DAG.getNode(ISD::SHL, SL, VT, Trunc, Amt);
14717+
return DAG.getNode(ISD::SHL, DL, VT, Trunc, Amt);
1472114718
}
1472214719
}
1472314720

@@ -14733,7 +14730,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1473314730
TLI.isTruncateFree(SrcVT.getScalarType(), VT.getScalarType()) &&
1473414731
// Avoid creating illegal types if running after type legalizer.
1473514732
(!LegalTypes || TLI.isTypeLegal(VT.getScalarType()))) {
14736-
SDLoc DL(N);
1473714733
EVT SVT = VT.getScalarType();
1473814734
SmallVector<SDValue, 8> TruncOps;
1473914735
for (const SDValue &Op : N0->op_values()) {
@@ -14747,7 +14743,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1474714743
if (N0.getOpcode() == ISD::SPLAT_VECTOR &&
1474814744
(!LegalTypes || TLI.isTypeLegal(VT.getScalarType())) &&
1474914745
(!LegalOperations || TLI.isOperationLegal(ISD::SPLAT_VECTOR, VT))) {
14750-
SDLoc DL(N);
1475114746
EVT SVT = VT.getScalarType();
1475214747
return DAG.getSplatVector(
1475314748
VT, DL, DAG.getNode(ISD::TRUNCATE, DL, SVT, N0->getOperand(0)));
@@ -14779,7 +14774,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1477914774
for (unsigned i = 0, e = BuildVecNumElts; i != e; i += TruncEltOffset)
1478014775
Opnds.push_back(BuildVect.getOperand(i));
1478114776

14782-
return DAG.getBuildVector(VT, SDLoc(N), Opnds);
14777+
return DAG.getBuildVector(VT, DL, Opnds);
1478314778
}
1478414779
}
1478514780

@@ -14842,7 +14837,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1484214837
AddToWorklist(NV.getNode());
1484314838
Opnds.push_back(NV);
1484414839
}
14845-
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, Opnds);
14840+
return DAG.getNode(ISD::CONCAT_VECTORS, DL, VT, Opnds);
1484614841
}
1484714842
}
1484814843

@@ -14856,11 +14851,9 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1485614851
if (VecSrcVT.isVector() && VecSrcVT.getScalarType() == VT &&
1485714852
(!LegalOperations ||
1485814853
TLI.isOperationLegal(ISD::EXTRACT_VECTOR_ELT, VecSrcVT))) {
14859-
SDLoc SL(N);
14860-
1486114854
unsigned Idx = isLE ? 0 : VecSrcVT.getVectorNumElements() - 1;
14862-
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, SL, VT, VecSrc,
14863-
DAG.getVectorIdxConstant(Idx, SL));
14855+
return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, VecSrc,
14856+
DAG.getVectorIdxConstant(Idx, DL));
1486414857
}
1486514858
}
1486614859

@@ -14905,7 +14898,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1490514898
// we are extra cautious to not create an unsupported operation.
1490614899
// Target-specific changes are likely needed to avoid regressions here.
1490714900
if (VT.isScalarInteger() || TLI.isOperationLegal(N0.getOpcode(), VT)) {
14908-
SDLoc DL(N);
1490914901
SDValue NarrowL = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
1491014902
SDValue NarrowR = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(1));
1491114903
return DAG.getNode(N0.getOpcode(), DL, VT, NarrowL, NarrowR);
@@ -14922,7 +14914,6 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1492214914
if (((!LegalOperations && N0.getOpcode() == ISD::UADDO_CARRY) ||
1492314915
TLI.isOperationLegal(N0.getOpcode(), VT)) &&
1492414916
N0.hasOneUse() && !N0->hasAnyUseOfValue(1)) {
14925-
SDLoc DL(N);
1492614917
SDValue X = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(0));
1492714918
SDValue Y = DAG.getNode(ISD::TRUNCATE, DL, VT, N0.getOperand(1));
1492814919
SDVTList VTs = DAG.getVTList(VT, N0->getValueType(1));
@@ -14939,7 +14930,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1493914930
VT.getScalarSizeInBits() &&
1494014931
hasOperation(N0.getOpcode(), VT)) {
1494114932
return getTruncatedUSUBSAT(VT, SrcVT, N0.getOperand(0), N0.getOperand(1),
14942-
DAG, SDLoc(N));
14933+
DAG, DL);
1494314934
}
1494414935
break;
1494514936
}

0 commit comments

Comments
 (0)