Phi speculation improvement for BasicAA

This is a partial solution to PR14351. It removes some of the special
significance of the first incoming phi value in the phi aliasing checking logic
in BasicAA. In the context of a loop, the old logic assumes that the first
incoming value is the interesting one (meaning that it is the one that comes
from outside the loop), but this is often not the case.  With this change, we
now test first the incoming value that comes from a block other than the parent
of the phi being tested.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168245 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hal Finkel
2012-11-17 02:33:15 +00:00
parent eed64a9c8d
commit c37f502d48
2 changed files with 83 additions and 3 deletions

View File

@@ -1065,9 +1065,15 @@ BasicAliasAnalysis::aliasPHI(const PHINode *PN, uint64_t PNSize,
if (PN > V2)
std::swap(Locs.first, Locs.second);
// Find the first incoming phi value not from its parent.
unsigned f = 0;
while (PN->getIncomingBlock(f) == PN->getParent() &&
f < PN->getNumIncomingValues()-1)
++f;
AliasResult Alias =
aliasCheck(PN->getIncomingValue(0), PNSize, PNTBAAInfo,
PN2->getIncomingValueForBlock(PN->getIncomingBlock(0)),
aliasCheck(PN->getIncomingValue(f), PNSize, PNTBAAInfo,
PN2->getIncomingValueForBlock(PN->getIncomingBlock(f)),
V2Size, V2TBAAInfo);
if (Alias == MayAlias)
return MayAlias;
@@ -1096,7 +1102,10 @@ BasicAliasAnalysis::aliasPHI(const PHINode *PN, uint64_t PNSize,
ArePhisAssumedNoAlias = true;
}
for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) {
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
if (i == f)
continue;
AliasResult ThisAlias =
aliasCheck(PN->getIncomingValue(i), PNSize, PNTBAAInfo,
PN2->getIncomingValueForBlock(PN->getIncomingBlock(i)),