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.
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);
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,