[llvm] f1d0a48 - [DAG] foldABSToABD - share the same SDLoc argument instead of recreating it over and over again.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 04:25:50 PDT 2024
Author: Simon Pilgrim
Date: 2024-03-15T11:25:33Z
New Revision: f1d0a48b2740b506d0b476f7cac0ee47d659a6d2
URL: https://github.com/llvm/llvm-project/commit/f1d0a48b2740b506d0b476f7cac0ee47d659a6d2
DIFF: https://github.com/llvm/llvm-project/commit/f1d0a48b2740b506d0b476f7cac0ee47d659a6d2.diff
LOG: [DAG] foldABSToABD - share the same SDLoc argument instead of recreating it over and over again.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 5a2a33fdcda98f..b6a5925123f13f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -598,7 +598,7 @@ namespace {
SDValue foldLogicOfSetCCs(bool IsAnd, SDValue N0, SDValue N1,
const SDLoc &DL);
SDValue foldSubToUSubSat(EVT DstVT, SDNode *N, const SDLoc &DL);
- SDValue foldABSToABD(SDNode *N);
+ SDValue foldABSToABD(SDNode *N, const SDLoc &DL);
SDValue unfoldMaskedMerge(SDNode *N);
SDValue unfoldExtremeBitClearingToShifts(SDNode *N);
SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond,
@@ -10720,7 +10720,7 @@ SDValue DAGCombiner::visitSHLSAT(SDNode *N) {
// (ABS (SUB (EXTEND a), (EXTEND b))).
// (TRUNC (ABS (SUB (EXTEND a), (EXTEND b)))).
// Generates UABD/SABD instruction.
-SDValue DAGCombiner::foldABSToABD(SDNode *N) {
+SDValue DAGCombiner::foldABSToABD(SDNode *N, const SDLoc &DL) {
EVT SrcVT = N->getValueType(0);
if (N->getOpcode() == ISD::TRUNCATE)
@@ -10732,7 +10732,6 @@ SDValue DAGCombiner::foldABSToABD(SDNode *N) {
EVT VT = N->getValueType(0);
SDValue AbsOp1 = N->getOperand(0);
SDValue Op0, Op1;
- SDLoc DL(N);
if (AbsOp1.getOpcode() != ISD::SUB)
return SDValue();
@@ -10791,9 +10790,10 @@ SDValue DAGCombiner::foldABSToABD(SDNode *N) {
SDValue DAGCombiner::visitABS(SDNode *N) {
SDValue N0 = N->getOperand(0);
EVT VT = N->getValueType(0);
+ SDLoc DL(N);
// fold (abs c1) -> c2
- if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, SDLoc(N), VT, {N0}))
+ if (SDValue C = DAG.FoldConstantArithmetic(ISD::ABS, DL, VT, {N0}))
return C;
// fold (abs (abs x)) -> (abs x)
if (N0.getOpcode() == ISD::ABS)
@@ -10802,7 +10802,7 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
if (DAG.SignBitIsZero(N0))
return N0;
- if (SDValue ABD = foldABSToABD(N))
+ if (SDValue ABD = foldABSToABD(N, DL))
return ABD;
// fold (abs (sign_extend_inreg x)) -> (zero_extend (abs (truncate x)))
@@ -10812,7 +10812,6 @@ SDValue DAGCombiner::visitABS(SDNode *N) {
if (TLI.isTruncateFree(VT, ExtVT) && TLI.isZExtFree(ExtVT, VT) &&
TLI.isTypeDesirableForOp(ISD::ABS, ExtVT) &&
hasOperation(ISD::ABS, ExtVT)) {
- SDLoc DL(N);
return DAG.getNode(
ISD::ZERO_EXTEND, DL, VT,
DAG.getNode(ISD::ABS, DL, ExtVT,
@@ -14720,7 +14719,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
if (SDValue V = foldSubToUSubSat(VT, N0.getNode(), DL))
return V;
- if (SDValue ABD = foldABSToABD(N))
+ if (SDValue ABD = foldABSToABD(N, DL))
return ABD;
// Attempt to pre-truncate BUILD_VECTOR sources.
More information about the llvm-commits
mailing list