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 | 528b1465e5efb7ccc56946cb247f67903bfa0339 (patch) | |
| tree | 7d8cd83b3f49d88f160aa2a0ea0a488f1cbaa785 /llvm/lib | |
| parent | c854c6655759fd0e5ee629c39362e9f7785565b2 (diff) | |
| download | bcm5719-llvm-528b1465e5efb7ccc56946cb247f67903bfa0339.tar.gz bcm5719-llvm-528b1465e5efb7ccc56946cb247f67903bfa0339.zip | |
Before converting an operand to mem, check if it is legal to do so.
llvm-svn: 97211
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/PIC16/PIC16ISelLowering.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16ISelLowering.cpp b/llvm/lib/Target/PIC16/PIC16ISelLowering.cpp index d2fc8db91f7..e167bdad1c3 100644 --- a/llvm/lib/Target/PIC16/PIC16ISelLowering.cpp +++ b/llvm/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; } |

