Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.200 -> 1.201 --- Log message: Can't move a load node if it's chain is not used. --- Diffs of the changes: (+22 -1) DAGCombiner.cpp | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletion(-) Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.200 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.201 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.200 Mon Sep 25 16:11:32 2006 +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Sep 26 02:37:42 2006 @@ -240,6 +240,10 @@ 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 @@ 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 @@ 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, _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits