aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-07-26 19:03:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-07-26 19:04:23 +0000
commit7fa27ce4a07f19b07799a767fc29416f3b625afb (patch)
tree27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/Transforms/Utils/LoopSimplify.cpp
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopSimplify.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
index 87a0e54e2704..3e604fdf2e11 100644
--- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -448,16 +448,15 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader,
// backedge blocks to jump to the BEBlock instead of the header.
// If one of the backedges has llvm.loop metadata attached, we remove
// it from the backedge and add it to BEBlock.
- unsigned LoopMDKind = BEBlock->getContext().getMDKindID("llvm.loop");
MDNode *LoopMD = nullptr;
for (BasicBlock *BB : BackedgeBlocks) {
Instruction *TI = BB->getTerminator();
if (!LoopMD)
- LoopMD = TI->getMetadata(LoopMDKind);
- TI->setMetadata(LoopMDKind, nullptr);
+ LoopMD = TI->getMetadata(LLVMContext::MD_loop);
+ TI->setMetadata(LLVMContext::MD_loop, nullptr);
TI->replaceSuccessorWith(Header, BEBlock);
}
- BEBlock->getTerminator()->setMetadata(LoopMDKind, LoopMD);
+ BEBlock->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopMD);
//===--- Update all analyses which we must preserve now -----------------===//
@@ -693,12 +692,6 @@ ReprocessLoop:
}
}
- // Changing exit conditions for blocks may affect exit counts of this loop and
- // any of its paretns, so we must invalidate the entire subtree if we've made
- // any changes.
- if (Changed && SE)
- SE->forgetTopmostLoop(L);
-
if (MSSAU && VerifyMemorySSA)
MSSAU->getMemorySSA()->verifyMemorySSA();
@@ -737,6 +730,13 @@ bool llvm::simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI,
Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, DT, LI, SE,
AC, MSSAU, PreserveLCSSA);
+ // Changing exit conditions for blocks may affect exit counts of this loop and
+ // any of its parents, so we must invalidate the entire subtree if we've made
+ // any changes. Do this here rather than in simplifyOneLoop() as the top-most
+ // loop is going to be the same for all child loops.
+ if (Changed && SE)
+ SE->forgetTopmostLoop(L);
+
return Changed;
}