[llvm] cdb36d4 - [DAG] foldAndToUsubsat/foldSubToUSubSat - 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:49 PDT 2024
Author: Simon Pilgrim
Date: 2024-03-15T11:25:33Z
New Revision: cdb36d47b79fc782f71842c8ad12b7788d451fb0
URL: https://github.com/llvm/llvm-project/commit/cdb36d47b79fc782f71842c8ad12b7788d451fb0
DIFF: https://github.com/llvm/llvm-project/commit/cdb36d47b79fc782f71842c8ad12b7788d451fb0.diff
LOG: [DAG] foldAndToUsubsat/foldSubToUSubSat - 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 314cda13fb5c22..5a2a33fdcda98f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -597,7 +597,7 @@ namespace {
SDValue foldSextSetcc(SDNode *N);
SDValue foldLogicOfSetCCs(bool IsAnd, SDValue N0, SDValue N1,
const SDLoc &DL);
- SDValue foldSubToUSubSat(EVT DstVT, SDNode *N);
+ SDValue foldSubToUSubSat(EVT DstVT, SDNode *N, const SDLoc &DL);
SDValue foldABSToABD(SDNode *N);
SDValue unfoldMaskedMerge(SDNode *N);
SDValue unfoldExtremeBitClearingToShifts(SDNode *N);
@@ -3596,7 +3596,7 @@ static SDValue getTruncatedUSUBSAT(EVT DstVT, EVT SrcVT, SDValue LHS,
// Try to find umax(a,b) - b or a - umin(a,b) patterns that may be converted to
// usubsat(a,b), optionally as a truncated type.
-SDValue DAGCombiner::foldSubToUSubSat(EVT DstVT, SDNode *N) {
+SDValue DAGCombiner::foldSubToUSubSat(EVT DstVT, SDNode *N, const SDLoc &DL) {
if (N->getOpcode() != ISD::SUB ||
!(!LegalOperations || hasOperation(ISD::USUBSAT, DstVT)))
return SDValue();
@@ -3611,18 +3611,18 @@ SDValue DAGCombiner::foldSubToUSubSat(EVT DstVT, SDNode *N) {
SDValue MaxLHS = Op0.getOperand(0);
SDValue MaxRHS = Op0.getOperand(1);
if (MaxLHS == Op1)
- return getTruncatedUSUBSAT(DstVT, SubVT, MaxRHS, Op1, DAG, SDLoc(N));
+ return getTruncatedUSUBSAT(DstVT, SubVT, MaxRHS, Op1, DAG, DL);
if (MaxRHS == Op1)
- return getTruncatedUSUBSAT(DstVT, SubVT, MaxLHS, Op1, DAG, SDLoc(N));
+ return getTruncatedUSUBSAT(DstVT, SubVT, MaxLHS, Op1, DAG, DL);
}
if (Op1.getOpcode() == ISD::UMIN && Op1.hasOneUse()) {
SDValue MinLHS = Op1.getOperand(0);
SDValue MinRHS = Op1.getOperand(1);
if (MinLHS == Op0)
- return getTruncatedUSUBSAT(DstVT, SubVT, Op0, MinRHS, DAG, SDLoc(N));
+ return getTruncatedUSUBSAT(DstVT, SubVT, Op0, MinRHS, DAG, DL);
if (MinRHS == Op0)
- return getTruncatedUSUBSAT(DstVT, SubVT, Op0, MinLHS, DAG, SDLoc(N));
+ return getTruncatedUSUBSAT(DstVT, SubVT, Op0, MinLHS, DAG, DL);
}
// sub(a,trunc(umin(zext(a),b))) -> usubsat(a,trunc(umin(b,SatLimit)))
@@ -3633,10 +3633,10 @@ SDValue DAGCombiner::foldSubToUSubSat(EVT DstVT, SDNode *N) {
SDValue MinRHS = Op1.getOperand(0).getOperand(1);
if (MinLHS.getOpcode() == ISD::ZERO_EXTEND && MinLHS.getOperand(0) == Op0)
return getTruncatedUSUBSAT(DstVT, MinLHS.getValueType(), MinLHS, MinRHS,
- DAG, SDLoc(N));
+ DAG, DL);
if (MinRHS.getOpcode() == ISD::ZERO_EXTEND && MinRHS.getOperand(0) == Op0)
return getTruncatedUSUBSAT(DstVT, MinLHS.getValueType(), MinRHS, MinLHS,
- DAG, SDLoc(N));
+ DAG, DL);
}
return SDValue();
@@ -3831,7 +3831,7 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
if (SDValue V = foldAddSubMasked1(false, N0, N1, DAG, SDLoc(N)))
return V;
- if (SDValue V = foldSubToUSubSat(VT, N))
+ if (SDValue V = foldSubToUSubSat(VT, N, DL))
return V;
// (A - B) - 1 -> add (xor B, -1), A
@@ -6655,7 +6655,7 @@ static SDValue combineShiftAnd1ToBitTest(SDNode *And, SelectionDAG &DAG) {
/// For targets that support usubsat, match a bit-hack form of that operation
/// that ends in 'and' and convert it.
-static SDValue foldAndToUsubsat(SDNode *N, SelectionDAG &DAG) {
+static SDValue foldAndToUsubsat(SDNode *N, SelectionDAG &DAG, const SDLoc &DL) {
EVT VT = N->getValueType(0);
unsigned BitWidth = VT.getScalarSizeInBits();
APInt SignMask = APInt::getSignMask(BitWidth);
@@ -6672,7 +6672,6 @@ static SDValue foldAndToUsubsat(SDNode *N, SelectionDAG &DAG) {
m_SpecificInt(BitWidth - 1))))))
return SDValue();
- SDLoc DL(N);
return DAG.getNode(ISD::USUBSAT, DL, VT, X,
DAG.getConstant(SignMask, DL, VT));
}
@@ -7164,7 +7163,7 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
return DAG.getNode(ISD::ZERO_EXTEND, DL, VT, N0.getOperand(0));
if (hasOperation(ISD::USUBSAT, VT))
- if (SDValue V = foldAndToUsubsat(N, DAG))
+ if (SDValue V = foldAndToUsubsat(N, DAG, DL))
return V;
// Postpone until legalization completed to avoid interference with bswap
@@ -14718,7 +14717,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
}
}
- if (SDValue V = foldSubToUSubSat(VT, N0.getNode()))
+ if (SDValue V = foldSubToUSubSat(VT, N0.getNode(), DL))
return V;
if (SDValue ABD = foldABSToABD(N))
More information about the llvm-commits
mailing list