Before converting an operand to mem, check if it is legal to do so.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjiv Gupta 2010-02-26 07:27:35 +00:00
parent 5478b6b6f6
commit 917733eca0

View File

@ -1527,10 +1527,24 @@ bool PIC16TargetLowering::NeedToConvertToMemOp(SDValue Op, unsigned &MemOp,
return true; return true;
if (isDirectLoad(Op.getOperand(1))) { if (isDirectLoad(Op.getOperand(1))) {
if (Op.getOperand(1).hasOneUse()) if (Op.getOperand(1).hasOneUse()) {
return false; // Legal and profitable folding check uses the NodeId of DAG nodes.
else // This NodeId is assigned by topological order. Therefore first
MemOp = 1; // assign topological order then perform legal and profitable check.
// Note:- Though this ordering is done before begining with legalization,
// newly added node during legalization process have NodeId=-1 (NewNode)
// therefore before performing any check proper ordering of the node is
// required.
DAG.AssignTopologicalOrder();
// Direct load operands are folded in binary operations. But before folding
// verify if this folding is legal. Fold only if it is legal otherwise
// convert this direct load to a separate memory operation.
if(ISel->IsLegalToFold(Op.getOperand(1), Op.getNode(), Op.getNode()))
return false;
else
MemOp = 1;
}
} }
return true; return true;
} }