aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopPeel.cpp
diff options
context:
space:
mode:
authorDmitry Makogon <d.makogon@g.nsu.ru>2021-11-02 23:09:37 +0700
committerDmitry Makogon <d.makogon@g.nsu.ru>2021-11-02 23:12:04 +0700
commite09958d5eb74a9ca0e1bda93e1e292c1a3cfadb3 (patch)
treedddec0393b98b8999ee8144358693cd15916a1ae /llvm/lib/Transforms/Utils/LoopPeel.cpp
parente2024d72fae778e0369127e078a40b4d6eb6c7bd (diff)
downloadllvm-e09958d5eb74a9ca0e1bda93e1e292c1a3cfadb3.zip
llvm-e09958d5eb74a9ca0e1bda93e1e292c1a3cfadb3.tar.gz
llvm-e09958d5eb74a9ca0e1bda93e1e292c1a3cfadb3.tar.bz2
[LoopPeel] Peel loops with exits followed by an unreachable or deopt block
Added support for peeling loops with exits that are followed either by an unreachable-terminated block or block that has a terminatnig deoptimize call. All blocks in the sequence must have an unique successor, maybe except for the last one. Reviewed By: mkazantsev Differential Revision: https://reviews.llvm.org/D110922
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopPeel.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp
index b2fe564..d6bdc1b 100644
--- a/llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -103,15 +103,15 @@ bool llvm::canPeel(Loop *L) {
SmallVector<BasicBlock *, 4> Exits;
L->getUniqueNonLatchExitBlocks(Exits);
// The latch must either be the only exiting block or all non-latch exit
- // blocks have either a deopt or unreachable terminator. Both deopt and
- // unreachable terminators are a strong indication they are not taken. Note
- // that this is a profitability check, not a legality check. Also note that
- // LoopPeeling currently can only update the branch weights of latch blocks
- // and branch weights to blocks with deopt or unreachable do not need
+ // blocks have either a deopt or unreachable terminator or compose a chain of
+ // blocks where the last one is either deopt or unreachable terminated. Both
+ // deopt and unreachable terminators are a strong indication they are not
+ // taken. Note that this is a profitability check, not a legality check. Also
+ // note that LoopPeeling currently can only update the branch weights of latch
+ // blocks and branch weights to blocks with deopt or unreachable do not need
// updating.
return all_of(Exits, [](const BasicBlock *BB) {
- return BB->getTerminatingDeoptimizeCall() ||
- isa<UnreachableInst>(BB->getTerminator());
+ return IsBlockFollowedByDeoptOrUnreachable(BB);
});
}