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
This commit is contained in:
Jim Laskey 2006-09-26 07:37:42 +00:00
parent e87e1154a1
commit 172585b3aa

View File

@ -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,