[llvm] c88b84d - [DAG] visitOR/visitORLike - merge repeated SDLoc calls.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 22 02:28:29 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-22T10:28:02+01:00
New Revision: c88b84d467a201129e329b0bca3425fef326db03
URL: https://github.com/llvm/llvm-project/commit/c88b84d467a201129e329b0bca3425fef326db03
DIFF: https://github.com/llvm/llvm-project/commit/c88b84d467a201129e329b0bca3425fef326db03.diff
LOG: [DAG] visitOR/visitORLike - merge repeated SDLoc calls.
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 3cdb801bae7bc0..0c3eb3cabc885f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -457,7 +457,7 @@ namespace {
SDValue visitAND(SDNode *N);
SDValue visitANDLike(SDValue N0, SDValue N1, SDNode *N);
SDValue visitOR(SDNode *N);
- SDValue visitORLike(SDValue N0, SDValue N1, SDNode *N);
+ SDValue visitORLike(SDValue N0, SDValue N1, const SDLoc &DL);
SDValue visitXOR(SDNode *N);
SDValue SimplifyVCastOp(SDNode *N, const SDLoc &DL);
SDValue SimplifyVBinOp(SDNode *N, const SDLoc &DL);
@@ -7566,9 +7566,8 @@ SDValue DAGCombiner::MatchBSwapHWord(SDNode *N, SDValue N0, SDValue N1) {
/// This contains all DAGCombine rules which reduce two values combined by
/// an Or operation to a single value \see visitANDLike().
-SDValue DAGCombiner::visitORLike(SDValue N0, SDValue N1, SDNode *N) {
+SDValue DAGCombiner::visitORLike(SDValue N0, SDValue N1, const SDLoc &DL) {
EVT VT = N1.getValueType();
- SDLoc DL(N);
// fold (or x, undef) -> -1
if (!LegalOperations && (N0.isUndef() || N1.isUndef()))
@@ -7702,23 +7701,24 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
SDValue N0 = N->getOperand(0);
SDValue N1 = N->getOperand(1);
EVT VT = N1.getValueType();
+ SDLoc DL(N);
// x | x --> x
if (N0 == N1)
return N0;
// fold (or c1, c2) -> c1|c2
- if (SDValue C = DAG.FoldConstantArithmetic(ISD::OR, SDLoc(N), VT, {N0, N1}))
+ if (SDValue C = DAG.FoldConstantArithmetic(ISD::OR, DL, VT, {N0, N1}))
return C;
// canonicalize constant to RHS
if (DAG.isConstantIntBuildVectorOrConstantInt(N0) &&
!DAG.isConstantIntBuildVectorOrConstantInt(N1))
- return DAG.getNode(ISD::OR, SDLoc(N), VT, N1, N0);
+ return DAG.getNode(ISD::OR, DL, VT, N1, N0);
// fold vector ops
if (VT.isVector()) {
- if (SDValue FoldedVOp = SimplifyVBinOp(N, SDLoc(N)))
+ if (SDValue FoldedVOp = SimplifyVBinOp(N, DL))
return FoldedVOp;
// fold (or x, 0) -> x, vector edition
@@ -7728,7 +7728,7 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
// fold (or x, -1) -> -1, vector edition
if (ISD::isConstantSplatVectorAllOnes(N1.getNode()))
// do not return N1, because undef node may exist in N1
- return DAG.getAllOnesConstant(SDLoc(N), N1.getValueType());
+ return DAG.getAllOnesConstant(DL, N1.getValueType());
// fold (or (shuf A, V_0, MA), (shuf B, V_0, MB)) -> (shuf A, B, Mask)
// Do this only if the resulting type / shuffle is legal.
@@ -7778,10 +7778,8 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
if (CanFold) {
SDValue NewLHS = ZeroN00 ? N0.getOperand(1) : N0.getOperand(0);
SDValue NewRHS = ZeroN10 ? N1.getOperand(1) : N1.getOperand(0);
-
SDValue LegalShuffle =
- TLI.buildLegalVectorShuffle(VT, SDLoc(N), NewLHS, NewRHS,
- Mask, DAG);
+ TLI.buildLegalVectorShuffle(VT, DL, NewLHS, NewRHS, Mask, DAG);
if (LegalShuffle)
return LegalShuffle;
}
@@ -7808,7 +7806,7 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
if (SDValue R = foldAndOrOfSETCC(N, DAG))
return R;
- if (SDValue Combined = visitORLike(N0, N1, N))
+ if (SDValue Combined = visitORLike(N0, N1, DL))
return Combined;
if (SDValue Combined = combineCarryDiamond(DAG, TLI, N0, N1, N))
@@ -7821,12 +7819,12 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
return BSwap;
// reassociate or
- if (SDValue ROR = reassociateOps(ISD::OR, SDLoc(N), N0, N1, N->getFlags()))
+ if (SDValue ROR = reassociateOps(ISD::OR, DL, N0, N1, N->getFlags()))
return ROR;
// Fold or(vecreduce(x), vecreduce(y)) -> vecreduce(or(x, y))
- if (SDValue SD = reassociateReduction(ISD::VECREDUCE_OR, ISD::OR, SDLoc(N),
- VT, N0, N1))
+ if (SDValue SD =
+ reassociateReduction(ISD::VECREDUCE_OR, ISD::OR, DL, VT, N0, N1))
return SD;
// Canonicalize (or (and X, c1), c2) -> (and (or X, c2), c1|c2)
@@ -7840,7 +7838,7 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
{N1, N0.getOperand(1)})) {
SDValue IOR = DAG.getNode(ISD::OR, SDLoc(N0), VT, N0.getOperand(0), N1);
AddToWorklist(IOR.getNode());
- return DAG.getNode(ISD::AND, SDLoc(N), VT, COR, IOR);
+ return DAG.getNode(ISD::AND, DL, VT, COR, IOR);
}
}
@@ -7855,7 +7853,7 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
return V;
// See if this is some rotate idiom.
- if (SDValue Rot = MatchRotate(N0, N1, SDLoc(N)))
+ if (SDValue Rot = MatchRotate(N0, N1, DL))
return Rot;
if (SDValue Load = MatchLoadCombine(N))
@@ -11534,7 +11532,7 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
N2_2, Flags);
}
// Otherwise see if we can optimize to a better pattern.
- if (SDValue Combined = visitORLike(N0, N2_0, N))
+ if (SDValue Combined = visitORLike(N0, N2_0, DL))
return DAG.getNode(ISD::SELECT, DL, N1.getValueType(), Combined, N1,
N2_2, Flags);
}
More information about the llvm-commits
mailing list