Skip to content

Commit f1d0a48

Browse files
committed
[DAG] foldABSToABD - share the same SDLoc argument instead of recreating it over and over again.
1 parent cdb36d4 commit f1d0a48

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ namespace {
598598
SDValue foldLogicOfSetCCs(bool IsAnd, SDValue N0, SDValue N1,
599599
const SDLoc &DL);
600600
SDValue foldSubToUSubSat(EVT DstVT, SDNode *N, const SDLoc &DL);
601-
SDValue foldABSToABD(SDNode *N);
601+
SDValue foldABSToABD(SDNode *N, const SDLoc &DL);
602602
SDValue unfoldMaskedMerge(SDNode *N);
603603
SDValue unfoldExtremeBitClearingToShifts(SDNode *N);
604604
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond,
@@ -10720,7 +10720,7 @@ SDValue DAGCombiner::visitSHLSAT(SDNode *N) {
1072010720
// (ABS (SUB (EXTEND a), (EXTEND b))).
1072110721
// (TRUNC (ABS (SUB (EXTEND a), (EXTEND b)))).
1072210722
// Generates UABD/SABD instruction.
10723-
SDValue DAGCombiner::foldABSToABD(SDNode *N) {
10723+
SDValue DAGCombiner::foldABSToABD(SDNode *N, const SDLoc &DL) {
1072410724
EVT SrcVT = N->getValueType(0);
1072510725

1072610726
if (N->getOpcode() == ISD::TRUNCATE)
@@ -10732,7 +10732,6 @@ SDValue DAGCombiner::foldABSToABD(SDNode *N) {
1073210732
EVT VT = N->getValueType(0);
1073310733
SDValue AbsOp1 = N->getOperand(0);
1073410734
SDValue Op0, Op1;
10735-
SDLoc DL(N);
1073610735

1073710736
if (AbsOp1.getOpcode() != ISD::SUB)
1073810737
return SDValue();
@@ -10791,9 +10790,10 @@ SDValue DAGCombiner::foldABSToABD(SDNode *N) {
1079110790
SDValue DAGCombiner::visitABS(SDNode *N) {
1079210791
SDValue N0 = N->getOperand(0);
1079310792
EVT VT = N->getValueType(0);
10793+
SDLoc DL(N);
1079410794

1079510795
// fold (abs c1) -> c2
10796-
if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, SDLoc(N), VT, {N0}))
10796+
if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, DL, VT, {N0}))
1079710797
return C;
1079810798
// fold (abs (abs x)) -> (abs x)
1079910799
if (N0.getOpcode() == ISD::ABS)
@@ -10802,7 +10802,7 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
1080210802
if (DAG.SignBitIsZero(N0))
1080310803
return N0;
1080410804

10805-
if (SDValue ABD = foldABSToABD(N))
10805+
if (SDValue ABD = foldABSToABD(N, DL))
1080610806
return ABD;
1080710807

1080810808
// fold (abs (sign_extend_inreg x)) -> (zero_extend (abs (truncate x)))
@@ -10812,7 +10812,6 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
1081210812
if (TLI.isTruncateFree(VT, ExtVT) && TLI.isZExtFree(ExtVT, VT) &&
1081310813
TLI.isTypeDesirableForOp(ISD::ABS, ExtVT) &&
1081410814
hasOperation(ISD::ABS, ExtVT)) {
10815-
SDLoc DL(N);
1081610815
return DAG.getNode(
1081710816
ISD::ZERO_EXTEND, DL, VT,
1081810817
DAG.getNode(ISD::ABS, DL, ExtVT,
@@ -14720,7 +14719,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
1472014719
if (SDValue V = foldSubToUSubSat(VT, N0.getNode(), DL))
1472114720
return V;
1472214721

14723-
if (SDValue ABD = foldABSToABD(N))
14722+
if (SDValue ABD = foldABSToABD(N, DL))
1472414723
return ABD;
1472514724

1472614725
// Attempt to pre-truncate BUILD_VECTOR sources.

0 commit comments

Comments
 (0)