diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-09-26 07:37:42 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-09-26 07:37:42 +0000 |
commit | 172585b3aac4444e22d250a68e59bc03b8837ef4 (patch) | |
tree | 3bf69c7f59dccf74d35d647c505c8ff508179d42 | |
parent | e87e1154a12b91f3c7a5dec8b946c7c9829deb16 (diff) |
Can't move a load node if it's chain is not used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30609 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index fbc4257263..93f8db1237 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -240,6 +240,10 @@ class VISIBILITY_HIDDEN DAGCombiner { SDOperand BuildUDIV(SDNode *N); SDNode *MatchRotate(SDOperand LHS, SDOperand RHS); + /// hasChainUsers - Returns true if one of the users of a load node has the + /// chain result as an operand. + bool hasChainUsers(SDNode *Load); + /// FindBaseOffset - Return true if we can determine base and offset /// information from a given pointer operand. Provides base and offset as a /// result. @@ -2640,7 +2644,7 @@ SDOperand DAGCombiner::visitLOAD(SDNode *N) { Chain.getOperand(1).getValueType() == N->getValueType(0)) return CombineTo(N, Chain.getOperand(1), Chain); - if (CombinerAA) { + if (CombinerAA && hasChainUsers(N)) { // Walk up chain skipping non-aliasing memory nodes. SDOperand BetterChain = FindBetterChain(N, Chain); @@ -3947,6 +3951,23 @@ SDOperand DAGCombiner::BuildUDIV(SDNode *N) { return S; } +/// hasChainUsers - Returns true if one of the users of a load node has the +/// chain result as an operand. +bool DAGCombiner::hasChainUsers(SDNode *Load) { + // Don't even bother if the load only has one user (conservatively the value.) + if (!Load->hasOneUse()) { + SDOperand Chain(Load, 1); + + for (SDNode::use_iterator UI = Load->use_begin(), UE = Load->use_end(); + UI != UE; ++UI) { + if ((*UI)->getOperand(0) == Chain) + return true; + } + } + + return false; +} + /// FindBaseOffset - Return true if we can determine base and offset information /// from a given pointer operand. Provides base and offset as a result. bool DAGCombiner::FindBaseOffset(SDOperand Ptr, |