[llvm-branch-commits] [llvm] [LICM] Drop per-iteration AA tags (PR #223530)
Zach Goldthorpe via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 15 06:59:34 PDT 2026
================
@@ -2361,13 +2389,31 @@ collectStoresWithInvariantAATags(MemorySSA *MSSA, DominatorTree *DT, Loop *L) {
StoresByLoc[MemoryLocation::get(SI)].push_back(SI);
});
+ // A scope declared inside the loop denotes a different scope on each
+ // iteration, so it cannot support the cross-iteration check below.
+ std::optional<SmallPtrSet<const MDNode *, 4>> LoopLocalAliasScopes;
+ auto HasLoopLocalAliasScope = [&](const AAMDNodes &AATags) {
+ if (!AATags.Scope && !AATags.NoAlias)
+ return false;
+ if (!LoopLocalAliasScopes)
+ LoopLocalAliasScopes = collectLoopLocalAliasScopes(L);
+ return hasAnyOperandsFrom(AATags.Scope, *LoopLocalAliasScopes) ||
+ hasAnyOperandsFrom(AATags.NoAlias, *LoopLocalAliasScopes);
+ };
+
// This only looks at explicit exiting blocks. If we ever start sinking
// stores into unwind edges, this will break.
SmallVector<BasicBlock *, 4> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);
SmallPtrSet<const StoreInst *, 8> StoresWithInvariantAATags;
- for (const auto &Stores : llvm::make_second_range(StoresByLoc)) {
+ for (const auto &Pair : StoresByLoc) {
+ const MemoryLocation &Loc = Pair.first;
+ const SmallVector<const StoreInst *, 1> &Stores = Pair.second;
----------------
zGoldthorpe wrote:
Unfortunately, using a structured binding within a lambda is a C++20 extension, so this was the best I could do instead...
https://github.com/llvm/llvm-project/pull/223530
More information about the llvm-branch-commits
mailing list