1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Make ScalarEvolutionAliasAnalysis slightly more aggressive, by making an

underlying alias call even for non-identified-object values.

llvm-svn: 85656
This commit is contained in:
Dan Gohman 2009-10-31 14:32:25 +00:00
parent 25091aa227
commit 7d09ca3e5b

View File

@ -38,7 +38,7 @@ namespace {
virtual AliasResult alias(const Value *V1, unsigned V1Size, virtual AliasResult alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size); const Value *V2, unsigned V2Size);
Value *GetUnderlyingIdentifiedObject(const SCEV *S); Value *GetBaseValue(const SCEV *S);
}; };
} // End of anonymous namespace } // End of anonymous namespace
@ -68,25 +68,22 @@ ScalarEvolutionAliasAnalysis::runOnFunction(Function &F) {
return false; return false;
} }
/// GetUnderlyingIdentifiedObject - Given an expression, try to find an /// GetBaseValue - Given an expression, try to find a
/// "identified object" (see AliasAnalysis::isIdentifiedObject) base /// base value. Return null is none was found.
/// value. Return null is none was found.
Value * Value *
ScalarEvolutionAliasAnalysis::GetUnderlyingIdentifiedObject(const SCEV *S) { ScalarEvolutionAliasAnalysis::GetBaseValue(const SCEV *S) {
if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) { if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) {
// In an addrec, assume that the base will be in the start, rather // In an addrec, assume that the base will be in the start, rather
// than the step. // than the step.
return GetUnderlyingIdentifiedObject(AR->getStart()); return GetBaseValue(AR->getStart());
} else if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(S)) { } else if (const SCEVAddExpr *A = dyn_cast<SCEVAddExpr>(S)) {
// If there's a pointer operand, it'll be sorted at the end of the list. // If there's a pointer operand, it'll be sorted at the end of the list.
const SCEV *Last = A->getOperand(A->getNumOperands()-1); const SCEV *Last = A->getOperand(A->getNumOperands()-1);
if (isa<PointerType>(Last->getType())) if (isa<PointerType>(Last->getType()))
return GetUnderlyingIdentifiedObject(Last); return GetBaseValue(Last);
} else if (const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S)) { } else if (const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S)) {
// Determine if we've found an Identified object. // This is a leaf node.
Value *V = U->getValue(); return U->getValue();
if (isIdentifiedObject(V))
return V;
} }
// No Identified object found. // No Identified object found.
return 0; return 0;
@ -120,8 +117,8 @@ ScalarEvolutionAliasAnalysis::alias(const Value *A, unsigned ASize,
// If ScalarEvolution can find an underlying object, form a new query. // If ScalarEvolution can find an underlying object, form a new query.
// The correctness of this depends on ScalarEvolution not recognizing // The correctness of this depends on ScalarEvolution not recognizing
// inttoptr and ptrtoint operators. // inttoptr and ptrtoint operators.
Value *AO = GetUnderlyingIdentifiedObject(AS); Value *AO = GetBaseValue(AS);
Value *BO = GetUnderlyingIdentifiedObject(BS); Value *BO = GetBaseValue(BS);
if ((AO && AO != A) || (BO && BO != B)) if ((AO && AO != A) || (BO && BO != B))
if (alias(AO ? AO : A, AO ? ~0u : ASize, if (alias(AO ? AO : A, AO ? ~0u : ASize,
BO ? BO : B, BO ? ~0u : BSize) == NoAlias) BO ? BO : B, BO ? ~0u : BSize) == NoAlias)