[llvm] r269235 - SDAG: Have SelectNodeTo replace uses if it CSE's instead of morphing a node
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 14:00:34 PDT 2016
Author: bogner
Date: Wed May 11 16:00:33 2016
New Revision: 269235
URL: http://llvm.org/viewvc/llvm-project?rev=269235&view=rev
Log:
SDAG: Have SelectNodeTo replace uses if it CSE's instead of morphing a node
It's awkward to force callers of SelectNodeTo to figure out whether
the node was morphed or CSE'd. Update uses here instead of requiring
callers to (sometimes) do it.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=269235&r1=269234&r2=269235&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed May 11 16:00:33 2016
@@ -5942,10 +5942,14 @@ SDNode *SelectionDAG::SelectNodeTo(SDNod
SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned MachineOpc,
SDVTList VTs,ArrayRef<SDValue> Ops) {
- N = MorphNodeTo(N, ~MachineOpc, VTs, Ops);
+ SDNode *New = MorphNodeTo(N, ~MachineOpc, VTs, Ops);
// Reset the NodeID to -1.
- N->setNodeId(-1);
- return N;
+ New->setNodeId(-1);
+ if (New != N) {
+ ReplaceAllUsesWith(N, New);
+ RemoveDeadNode(N);
+ }
+ return New;
}
/// UpdadeSDLocOnMergedSDNode - If the opt level is -O0 then it throws away
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=269235&r1=269234&r2=269235&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed May 11 16:00:33 2016
@@ -2127,12 +2127,7 @@ void SelectionDAGISel::Select_WRITE_REGI
}
void SelectionDAGISel::Select_UNDEF(SDNode *N) {
- SDNode *New =
- CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->getValueType(0));
- if (New != N) {
- ReplaceUses(N, New);
- CurDAG->RemoveDeadNode(N);
- }
+ CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->getValueType(0));
}
/// GetVBR - decode a vbr encoding whose top bit is set.
More information about the llvm-commits
mailing list