[llvm] 6713332 - [LoopVersioningLICM] Fix noalias metadata emission
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 09:58:15 PDT 2020
Author: Nikita Popov
Date: 2020-10-13T18:58:05+02:00
New Revision: 6713332fddb796f5b14fcb6a7e5d36979676e4ab
URL: https://github.com/llvm/llvm-project/commit/6713332fddb796f5b14fcb6a7e5d36979676e4ab
DIFF: https://github.com/llvm/llvm-project/commit/6713332fddb796f5b14fcb6a7e5d36979676e4ab.diff
LOG: [LoopVersioningLICM] Fix noalias metadata emission
The previous code added the scope on each iteration, so that the
same scope was represented many times in the same !noalias metadata.
That's legal, and semantically equivalent to only storing the scope
once, but it's also wasteful and may pessimize further optimization
if AATags get intersected naively, as done by the AliasSetTracker.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index 06b684ef1e70..06af4da92355 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -539,8 +539,8 @@ void LoopVersioningLICM::setNoAliasToLoop(Loop *VerLoop) {
MDBuilder MDB(I->getContext());
MDNode *NewDomain = MDB.createAnonymousAliasScopeDomain("LVDomain");
StringRef Name = "LVAliasScope";
- SmallVector<Metadata *, 4> Scopes, NoAliases;
MDNode *NewScope = MDB.createAnonymousAliasScope(NewDomain, Name);
+ SmallVector<Metadata *, 4> Scopes{NewScope}, NoAliases{NewScope};
// Iterate over each instruction of loop.
// set no-alias for all load & store instructions.
for (auto *Block : CurLoop->getBlocks()) {
@@ -548,8 +548,6 @@ void LoopVersioningLICM::setNoAliasToLoop(Loop *VerLoop) {
// Only interested in instruction that may modify or read memory.
if (!Inst.mayReadFromMemory() && !Inst.mayWriteToMemory())
continue;
- Scopes.push_back(NewScope);
- NoAliases.push_back(NewScope);
// Set no-alias for current instruction.
Inst.setMetadata(
LLVMContext::MD_noalias,
More information about the llvm-commits
mailing list