diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-15 20:06:30 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-15 20:06:30 +0000 |
commit | 8aa28b9c34f38f85b17ea1486682ec8fc7dd7b3b (patch) | |
tree | ef577db99de7b18d3a1a8cfffec2f1557eb9cedd /llvm/lib/CodeGen/SelectionDAG | |
parent | c2ac800cd75189c2cec12eab4d71398cbb442158 (diff) | |
download | bcm5719-llvm-8aa28b9c34f38f85b17ea1486682ec8fc7dd7b3b.tar.gz bcm5719-llvm-8aa28b9c34f38f85b17ea1486682ec8fc7dd7b3b.zip |
Generalize one of the SelectionDAG::ReplaceAllUsesWith overloads
to support replacing a node with another that has a superset of
the result types. Use this instead of calling
ReplaceAllUsesOfValueWith for each value.
llvm-svn: 69209
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 13 |
2 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 55a52b600a7..5932aebf5ca 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -4420,8 +4420,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { DAG.getVTList(&ValueVTs[0], 2), &Ops[0], 2); SDNode *RNode = Result.getNode(); - DAG.ReplaceAllUsesOfValueWith(SDValue(Node, 0), SDValue(RNode, 0)); - DAG.ReplaceAllUsesOfValueWith(SDValue(Node, 1), SDValue(RNode, 1)); + DAG.ReplaceAllUsesWith(Node, RNode); break; } } @@ -4456,8 +4455,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { DAG.getVTList(&ValueVTs[0], 2), &Ops[0], 2); SDNode *RNode = Result.getNode(); - DAG.ReplaceAllUsesOfValueWith(SDValue(Node, 0), SDValue(RNode, 0)); - DAG.ReplaceAllUsesOfValueWith(SDValue(Node, 1), SDValue(RNode, 1)); + DAG.ReplaceAllUsesWith(Node, RNode); break; } } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 022b961331a..4b8591eb856 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4500,14 +4500,17 @@ void SelectionDAG::ReplaceAllUsesWith(SDValue FromN, SDValue To, /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead. /// This can cause recursive merging of nodes in the DAG. /// -/// This version assumes From/To have matching types and numbers of result -/// values. +/// This version assumes that for each value of From, there is a +/// corresponding value in To in the same position with the same type. /// void SelectionDAG::ReplaceAllUsesWith(SDNode *From, SDNode *To, DAGUpdateListener *UpdateListener) { - assert(From->getVTList().VTs == To->getVTList().VTs && - From->getNumValues() == To->getNumValues() && - "Cannot use this version of ReplaceAllUsesWith!"); +#ifndef NDEBUG + for (unsigned i = 0, e = From->getNumValues(); i != e; ++i) + assert((!From->hasAnyUseOfValue(i) || + From->getValueType(i) == To->getValueType(i)) && + "Cannot use this version of ReplaceAllUsesWith!"); +#endif // Handle the trivial case. if (From == To) |