From: Chris Lattner Date: Thu, 13 Oct 2005 21:44:47 +0000 (+0000) Subject: When ExpandOp'ing a [SZ]EXTLOAD, make sure to remember that the chain X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9ad8481cfbbb9dfe451b771978098677bc8dd254;p=oota-llvm.git When ExpandOp'ing a [SZ]EXTLOAD, make sure to remember that the chain is also legal. Add support for ExpandOp'ing raw EXTLOADs too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23716 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 3fcf45afe38..3363c3d1feb 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3121,6 +3121,10 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ else Lo = DAG.getExtLoad(ISD::SEXTLOAD, NVT, Chain, Ptr, Node->getOperand(2), EVT); + + // Remember that we legalized the chain. + AddLegalizedOperand(SDOperand(Node, 1), Lo.getValue(1)); + // The high part is obtained by SRA'ing all but one of the bits of the lo // part. unsigned LoSize = MVT::getSizeInBits(Lo.getValueType()); @@ -3140,10 +3144,32 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){ else Lo = DAG.getExtLoad(ISD::ZEXTLOAD, NVT, Chain, Ptr, Node->getOperand(2), EVT); + + // Remember that we legalized the chain. + AddLegalizedOperand(SDOperand(Node, 1), Lo.getValue(1)); + // The high part is just a zero. - Hi = DAG.getConstant(0, NVT); + Hi = LegalizeOp(DAG.getConstant(0, NVT)); + Lo = LegalizeOp(Lo); + break; + } + case ISD::EXTLOAD: { + SDOperand Chain = LegalizeOp(Node->getOperand(0)); + SDOperand Ptr = LegalizeOp(Node->getOperand(1)); + MVT::ValueType EVT = cast(Node->getOperand(3))->getVT(); + + if (EVT == NVT) + Lo = DAG.getLoad(NVT, Chain, Ptr, Node->getOperand(2)); + else + Lo = DAG.getExtLoad(ISD::EXTLOAD, NVT, Chain, Ptr, Node->getOperand(2), + EVT); + + // Remember that we legalized the chain. + AddLegalizedOperand(SDOperand(Node, 1), Lo.getValue(1)); + + // The high part is undefined. + Hi = LegalizeOp(DAG.getNode(ISD::UNDEF, NVT)); Lo = LegalizeOp(Lo); - Hi = LegalizeOp(Hi); break; } case ISD::ANY_EXTEND: {