[llvm] r308348 - [DAG] Reverse node replacement in extension operation. NFCI.
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 12:49:20 PDT 2017
Author: niravd
Date: Tue Jul 18 12:49:20 2017
New Revision: 308348
URL: http://llvm.org/viewvc/llvm-project?rev=308348&view=rev
Log:
[DAG] Reverse node replacement in extension operation. NFCI.
Reorder replacements to be user first in preparation for multi-level
folding to premptively avoid inadvertantly deleting later nodes from
sharing found from replacement.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=308348&r1=308347&r2=308348&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jul 18 12:49:20 2017
@@ -7172,11 +7172,13 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SD
N0.getValueType(), ExtLoad);
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::SIGN_EXTEND);
// If the load value is used only by N, replace it via CombineTo N.
- if (N0.getValue(0).hasOneUse())
+ bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
+ CombineTo(N, ExtLoad);
+ if (NoReplaceTrunc)
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
else
CombineTo(LN0, Trunc, ExtLoad.getValue(1));
- return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked!
+ return SDValue(N, 0);
}
}
@@ -7233,12 +7235,13 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SD
SDLoc(N0.getOperand(0)),
N0.getOperand(0).getValueType(), ExtLoad);
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::SIGN_EXTEND);
- // If the load value is used only by N, replace it via CombineTo N.
- if (SDValue(LN0, 0).hasOneUse())
+ bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
+ CombineTo(N, And);
+ if (NoReplaceTrunc)
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
else
CombineTo(LN0, Trunc, ExtLoad.getValue(1));
- return CombineTo(N, And); // Return N so it doesn't get rechecked!
+ return SDValue(N,0); // Return N so it doesn't get rechecked!
}
}
}
@@ -7479,11 +7482,13 @@ SDValue DAGCombiner::visitZERO_EXTEND(SD
N0.getValueType(), ExtLoad);
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, SDLoc(N), ISD::ZERO_EXTEND);
// If the load value is used only by N, replace it via CombineTo N.
- if (SDValue(LN0, 0).hasOneUse())
+ bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
+ CombineTo(N, ExtLoad);
+ if (NoReplaceTrunc)
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
else
CombineTo(LN0, Trunc, ExtLoad.getValue(1));
- return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked!
+ return SDValue(N, 0); // Return N so it doesn't get rechecked!
}
}
@@ -7534,12 +7539,13 @@ SDValue DAGCombiner::visitZERO_EXTEND(SD
SDLoc(N0.getOperand(0)),
N0.getOperand(0).getValueType(), ExtLoad);
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, DL, ISD::ZERO_EXTEND);
- // If the load value is used only by N, replace it via CombineTo N.
- if (SDValue(LN0, 0).hasOneUse())
+ bool NoReplaceTrunc = SDValue(LN0, 0).hasOneUse();
+ CombineTo(N, And);
+ if (NoReplaceTrunc)
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
else
CombineTo(LN0, Trunc, ExtLoad.getValue(1));
- return CombineTo(N, And); // Return N so it doesn't get rechecked!
+ return SDValue(N,0); // Return N so it doesn't get rechecked!
}
}
}
@@ -7716,11 +7722,13 @@ SDValue DAGCombiner::visitANY_EXTEND(SDN
ExtendSetCCUses(SetCCs, Trunc, ExtLoad, SDLoc(N),
ISD::ANY_EXTEND);
// If the load value is used only by N, replace it via CombineTo N.
- if (N0.hasOneUse())
+ bool NoReplaceTrunc = N0.hasOneUse();
+ CombineTo(N, ExtLoad);
+ if (NoReplaceTrunc)
DAG.ReplaceAllUsesOfValueWith(SDValue(LN0, 1), ExtLoad.getValue(1));
else
CombineTo(LN0, Trunc, ExtLoad.getValue(1));
- return CombineTo(N, ExtLoad); // Return N so it doesn't get rechecked!
+ return SDValue(N, 0); // Return N so it doesn't get rechecked!
}
}
More information about the llvm-commits
mailing list