diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-26 07:27:35 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-26 07:27:35 +0000 |
commit | 917733eca0b5d25aeb86dc5793f898932926851c (patch) | |
tree | 32b272ab2314b7c90a390e8cdd7007476c9e4940 | |
parent | 5478b6b6f6c6ac6b3c2134175e5fa2f048a6f7f7 (diff) |
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
-rw-r--r-- | lib/Target/PIC16/PIC16ISelLowering.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Target/PIC16/PIC16ISelLowering.cpp b/lib/Target/PIC16/PIC16ISelLowering.cpp index d2fc8db91f..e167bdad1c 100644 --- a/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/lib/Target/PIC16/PIC16ISelLowering.cpp @@ -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; } |