aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Holewinski <jholewinski@nvidia.com>2013-03-20 14:51:01 +0000
committerJustin Holewinski <jholewinski@nvidia.com>2013-03-20 14:51:01 +0000
commitfa963a885c074b3b0d6cc2466036297c476f7103 (patch)
tree4b1a32ec7ede3d92d950ceb996967dc646c6a70f
parent06091513c283c863296f01cc7c2e86b56bb50d02 (diff)
Move SDNode order propagation to SDNodeOrdering, which also fixes a missed
case of order propagation during isel. Thanks Owen for the suggestion! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177525 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp31
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h1
-rw-r--r--lib/CodeGen/SelectionDAG/SDNodeOrdering.h4
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp2
4 files changed, 15 insertions, 23 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 1d6a981eec..b6436bf427 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -619,17 +619,6 @@ void DAGTypeLegalizer::RemapValue(SDValue &N) {
}
}
-/// PropagateOrdering - Propagate SDNode ordering information from \p Old to
-/// \p New. Generally, this just means copying the ordering value, but if the
-/// new node is actually a recycled node with a lower ordering already, then
-/// we do not want to propagate the new (higher) ordering.
-void DAGTypeLegalizer::PropagateOrdering(SDNode *Old, SDNode *New) {
- unsigned OldOrder = DAG.GetOrdering(Old);
- unsigned NewOrder = DAG.GetOrdering(New);
- if (NewOrder == 0 || (NewOrder > 0 && OldOrder < NewOrder))
- DAG.AssignOrdering(New, OldOrder);
-}
-
namespace {
/// NodeUpdateListener - This class is a DAGUpdateListener that listens for
/// updates to nodes and recomputes their ready state.
@@ -748,7 +737,7 @@ void DAGTypeLegalizer::SetPromotedInteger(SDValue Op, SDValue Result) {
OpEntry = Result;
// Propagate node ordering
- PropagateOrdering(Op.getNode(), Result.getNode());
+ DAG.AssignOrdering(Result.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {
@@ -762,7 +751,7 @@ void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {
OpEntry = Result;
// Propagate node ordering
- PropagateOrdering(Op.getNode(), Result.getNode());
+ DAG.AssignOrdering(Result.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::SetScalarizedVector(SDValue Op, SDValue Result) {
@@ -779,7 +768,7 @@ void DAGTypeLegalizer::SetScalarizedVector(SDValue Op, SDValue Result) {
OpEntry = Result;
// Propagate node ordering
- PropagateOrdering(Op.getNode(), Result.getNode());
+ DAG.AssignOrdering(Result.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::GetExpandedInteger(SDValue Op, SDValue &Lo,
@@ -809,8 +798,8 @@ void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,
Entry.second = Hi;
// Propagate ordering
- PropagateOrdering(Op.getNode(), Lo.getNode());
- PropagateOrdering(Op.getNode(), Hi.getNode());
+ DAG.AssignOrdering(Lo.getNode(), DAG.GetOrdering(Op.getNode()));
+ DAG.AssignOrdering(Hi.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::GetExpandedFloat(SDValue Op, SDValue &Lo,
@@ -840,8 +829,8 @@ void DAGTypeLegalizer::SetExpandedFloat(SDValue Op, SDValue Lo,
Entry.second = Hi;
// Propagate ordering
- PropagateOrdering(Op.getNode(), Lo.getNode());
- PropagateOrdering(Op.getNode(), Hi.getNode());
+ DAG.AssignOrdering(Lo.getNode(), DAG.GetOrdering(Op.getNode()));
+ DAG.AssignOrdering(Hi.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::GetSplitVector(SDValue Op, SDValue &Lo,
@@ -873,8 +862,8 @@ void DAGTypeLegalizer::SetSplitVector(SDValue Op, SDValue Lo,
Entry.second = Hi;
// Propagate ordering
- PropagateOrdering(Op.getNode(), Lo.getNode());
- PropagateOrdering(Op.getNode(), Hi.getNode());
+ DAG.AssignOrdering(Lo.getNode(), DAG.GetOrdering(Op.getNode()));
+ DAG.AssignOrdering(Hi.getNode(), DAG.GetOrdering(Op.getNode()));
}
void DAGTypeLegalizer::SetWidenedVector(SDValue Op, SDValue Result) {
@@ -888,7 +877,7 @@ void DAGTypeLegalizer::SetWidenedVector(SDValue Op, SDValue Result) {
OpEntry = Result;
// Propagate node ordering
- PropagateOrdering(Op.getNode(), Result.getNode());
+ DAG.AssignOrdering(Result.getNode(), DAG.GetOrdering(Op.getNode()));
}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index b8b5ba8c9a..27b3cf2abc 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
@@ -143,7 +143,6 @@ private:
void ExpungeNode(SDNode *N);
void PerformExpensiveChecks();
void RemapValue(SDValue &N);
- void PropagateOrdering(SDNode *Old, SDNode *New);
// Common routines.
SDValue BitConvertToInteger(SDValue Op);
diff --git a/lib/CodeGen/SelectionDAG/SDNodeOrdering.h b/lib/CodeGen/SelectionDAG/SDNodeOrdering.h
index d2269f8acc..74010a8096 100644
--- a/lib/CodeGen/SelectionDAG/SDNodeOrdering.h
+++ b/lib/CodeGen/SelectionDAG/SDNodeOrdering.h
@@ -34,7 +34,9 @@ public:
SDNodeOrdering() {}
void add(const SDNode *Node, unsigned O) {
- OrderMap[Node] = O;
+ unsigned OldOrder = getOrder(Node);
+ if (OldOrder == 0 || (OldOrder > 0 && O < OldOrder))
+ OrderMap[Node] = O;
}
void remove(const SDNode *Node) {
DenseMap<const SDNode*, unsigned>::iterator Itr = OrderMap.find(Node);
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 15001f506b..eeea9e4cfc 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -786,7 +786,9 @@ void SelectionDAGISel::DoInstructionSelection() {
continue;
// Replace node.
if (ResNode) {
+ // Propagate ordering
CurDAG->AssignOrdering(ResNode, CurDAG->GetOrdering(Node));
+
ReplaceUses(Node, ResNode);
}