diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-07 22:28:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-07 22:28:47 +0000 |
commit | 8afc48e44ad8868c1d41511db645e2ba1a4b894e (patch) | |
tree | 0e0b8cdbdd6429db2672b9cb14d51ae3b1082dda /lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | |
parent | c7af17923e3bb6053f529679ef0be5399d3519ed (diff) |
Fix a bug in load expansion legalization and ret legalization. This fixes
CodeGen/Generic/select.ll:castconst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 52389ec8ad..95bc3ab432 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -72,6 +72,11 @@ class SelectionDAGLegalize { /// more than once. std::map<SDOperand, std::pair<SDOperand, SDOperand> > ExpandedNodes; + void AddLegalizedOperand(SDOperand From, SDOperand To) { + bool isNew = LegalizedNodes.insert(std::make_pair(From, To)).second; + assert(isNew && "Got into the map somehow?"); + } + /// setValueTypeAction - Set the action for a particular value type. This /// assumes an action has not already been set for this value type. void setValueTypeAction(MVT::ValueType VT, LegalizeAction A) { @@ -323,7 +328,14 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) Result = DAG.getLoad(Node->getValueType(0), Tmp1, Tmp2); - break; + else + Result = SDOperand(Node, 0); + + // Since loads produce two values, make sure to remember that we legalized + // both of them. + AddLegalizedOperand(SDOperand(Node, 0), Result); + AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1)); + return Result.getValue(Op.ResNo); case ISD::EXTRACT_ELEMENT: // Get both the low and high parts. @@ -368,7 +380,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { switch (getTypeAction(Node->getOperand(1).getValueType())) { case Legal: Tmp2 = LegalizeOp(Node->getOperand(1)); - if (Tmp2 != Node->getOperand(1)) + if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1)) Result = DAG.getNode(ISD::RET, MVT::Other, Tmp1, Tmp2); break; case Expand: { @@ -550,10 +562,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; } - if (!Op.Val->hasOneUse()) { - bool isNew = LegalizedNodes.insert(std::make_pair(Op, Result)).second; - assert(isNew && "Got into the map somehow?"); - } + if (!Op.Val->hasOneUse()) + AddLegalizedOperand(Op, Result); return Result; } @@ -632,9 +642,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ Hi = DAG.getLoad(NVT, Lo.getValue(1), Ptr); // Remember that we legalized the chain. - bool isNew = LegalizedNodes.insert(std::make_pair(Op.getValue(1), - Hi.getValue(1))).second; - assert(isNew && "This node was already legalized!"); + AddLegalizedOperand(Op.getValue(1), Hi.getValue(1)); if (!TLI.isLittleEndian()) std::swap(Lo, Hi); break; |