1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

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

llvm-svn: 97211
This commit is contained in:
Sanjiv Gupta 2010-02-26 07:27:35 +00:00
parent 8a60e7080e
commit 7caf38490a

View File

@ -1527,10 +1527,24 @@ bool PIC16TargetLowering::NeedToConvertToMemOp(SDValue Op, unsigned &MemOp,
return true;
if (isDirectLoad(Op.getOperand(1))) {
if (Op.getOperand(1).hasOneUse())
return false;
else
MemOp = 1;
if (Op.getOperand(1).hasOneUse()) {
// Legal and profitable folding check uses the NodeId of DAG nodes.
// This NodeId is assigned by topological order. Therefore first
// 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;
}