Fix regression in combiner alias analysis.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey 2006-10-11 13:47:09 +00:00
parent 5aec0b061c
commit 7ca56aff22

View File

@ -248,6 +248,11 @@ namespace {
void GatherAllAliases(SDNode *N, SDOperand OriginalChain, void GatherAllAliases(SDNode *N, SDOperand OriginalChain,
SmallVector<SDOperand, 8> &Aliases); SmallVector<SDOperand, 8> &Aliases);
/// FindAliasInfo - Extracts the relevant alias information from the memory
/// node. Returns true if the operand was a load.
bool FindAliasInfo(SDNode *N,
SDOperand &Ptr, int64_t &Size, const Value *&SrcValue);
/// FindBetterChain - Walk up chain skipping non-aliasing memory nodes, /// FindBetterChain - Walk up chain skipping non-aliasing memory nodes,
/// looking for a better chain (aliasing node.) /// looking for a better chain (aliasing node.)
SDOperand FindBetterChain(SDNode *N, SDOperand Chain); SDOperand FindBetterChain(SDNode *N, SDOperand Chain);
@ -3951,8 +3956,8 @@ static bool FindBaseOffset(SDOperand Ptr, SDOperand &Base, int64_t &Offset) {
/// isAlias - Return true if there is any possibility that the two addresses /// isAlias - Return true if there is any possibility that the two addresses
/// overlap. /// overlap.
static bool isAlias(SDOperand Ptr1, int64_t Size1, SDOperand SrcValue1, static bool isAlias(SDOperand Ptr1, int64_t Size1, const Value *SrcValue1,
SDOperand Ptr2, int64_t Size2, SDOperand SrcValue2) { SDOperand Ptr2, int64_t Size2, const Value *SrcValue2) {
// If they are the same then they must be aliases. // If they are the same then they must be aliases.
if (Ptr1 == Ptr2) return true; if (Ptr1 == Ptr2) return true;
@ -3974,24 +3979,25 @@ static bool isAlias(SDOperand Ptr1, int64_t Size1, SDOperand SrcValue1,
/// FindAliasInfo - Extracts the relevant alias information from the memory /// FindAliasInfo - Extracts the relevant alias information from the memory
/// node. Returns true if the operand was a load. /// node. Returns true if the operand was a load.
static bool FindAliasInfo(SDNode *N, SDOperand &Ptr, int64_t &Size, bool DAGCombiner::FindAliasInfo(SDNode *N,
SDOperand &SrcValue, SelectionDAG &DAG) { SDOperand &Ptr, int64_t &Size, const Value *&SrcValue) {
switch (N->getOpcode()) { if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N)) {
case ISD::LOAD: Ptr = LD->getBasePtr();
if (!ISD::isNON_EXTLoad(N))
return false;
Ptr = N->getOperand(1);
Size = MVT::getSizeInBits(N->getValueType(0)) >> 3; Size = MVT::getSizeInBits(N->getValueType(0)) >> 3;
SrcValue = N->getOperand(2); SrcValue = LD->getSrcValue();
return true; return true;
case ISD::STORE: } else if (StoreSDNode *ST = dyn_cast<StoreSDNode>(N)) {
Ptr = N->getOperand(2); #if 1 //FIXME - Switch over after StoreSDNode comes online.
Size = MVT::getSizeInBits(N->getOperand(1).getValueType()) >> 3; Ptr = ST->getOperand(2);
SrcValue = N->getOperand(3); Size = MVT::getSizeInBits(ST->getOperand(1).getValueType()) >> 3;
break; SrcValue = 0;
default: #else
Ptr = ST->getBasePtr();
Size = MVT::getSizeInBits(ST->getOperand(1).getValueType()) >> 3;
SrcValue = ST->getSrcValue();
#endif
} else {
assert(0 && "FindAliasInfo expected a memory operand"); assert(0 && "FindAliasInfo expected a memory operand");
break;
} }
return false; return false;
@ -4007,8 +4013,8 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDOperand OriginalChain,
// Get alias information for node. // Get alias information for node.
SDOperand Ptr; SDOperand Ptr;
int64_t Size; int64_t Size;
SDOperand SrcValue; const Value *SrcValue;
bool IsLoad = FindAliasInfo(N, Ptr, Size, SrcValue, DAG); bool IsLoad = FindAliasInfo(N, Ptr, Size, SrcValue);
// Starting off. // Starting off.
Chains.push_back(OriginalChain); Chains.push_back(OriginalChain);
@ -4030,12 +4036,17 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDOperand OriginalChain,
break; break;
case ISD::LOAD: case ISD::LOAD:
if (!ISD::isNON_EXTLoad(N)) {
Aliases.push_back(Chain);
break;
}
// Pass thru.
case ISD::STORE: { case ISD::STORE: {
// Get alias information for Chain. // Get alias information for Chain.
SDOperand OpPtr; SDOperand OpPtr;
int64_t OpSize; int64_t OpSize;
SDOperand OpSrcValue; const Value *OpSrcValue;
bool IsOpLoad = FindAliasInfo(Chain.Val, OpPtr, OpSize, OpSrcValue, DAG); bool IsOpLoad = FindAliasInfo(Chain.Val, OpPtr, OpSize, OpSrcValue);
// If chain is alias then stop here. // If chain is alias then stop here.
if (!(IsLoad && IsOpLoad) && if (!(IsLoad && IsOpLoad) &&