diff options
author | Nikita Popov <npopov@redhat.com> | 2024-11-27 09:38:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-27 09:38:51 +0100 |
commit | e636434bdf74cf40071b776ef05aafbf161ce4cd (patch) | |
tree | 04e4deb5aba167f9751f47e55a17b8088122e41b /llvm/lib/Analysis/BasicAliasAnalysis.cpp | |
parent | c00e53208db638c35499fc80b555f8e14baa35f0 (diff) | |
download | llvm-e636434bdf74cf40071b776ef05aafbf161ce4cd.zip llvm-e636434bdf74cf40071b776ef05aafbf161ce4cd.tar.gz llvm-e636434bdf74cf40071b776ef05aafbf161ce4cd.tar.bz2 |
[BasicAA][LAA] Don't use same-block phis in cross iteration mode (#116802)
In 4de3184f07fd8c548125d315dd306d4afa7c9698 we exposed BasicAA's
cross-iteration mode for use in LAA, so we can handle selects with equal
conditions correctly (where the select condition is not actually equal
across iterations).
However, if we replace the selects with equivalent phis, the issue still
exists. In the phi case, we effectively still have an assumption that
the condition(s) that control which phi arg is used will be the same
across iterations. Fix this by disabling this phi handling in
cross-iteration mode.
(I'm not entirely sure whether this is also needed when BasicAA enables
cross-iteration mode during internal phi recursion, but I wouldn't be
surprised if that's the case.)
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 178ad86..381fb7b 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1449,9 +1449,10 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize, return AliasResult::NoAlias; // If the values are PHIs in the same block, we can do a more precise // as well as efficient check: just check for aliases between the values - // on corresponding edges. + // on corresponding edges. Don't do this if we are analyzing across + // iterations, as we may pick a different phi entry in different iterations. if (const PHINode *PN2 = dyn_cast<PHINode>(V2)) - if (PN2->getParent() == PN->getParent()) { + if (PN2->getParent() == PN->getParent() && !AAQI.MayBeCrossIteration) { std::optional<AliasResult> Alias; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { AliasResult ThisAlias = AAQI.AAR.alias( |