[PATCH] D110924: [LoopUtils] Consider unreachable-terminated blocks as deoptimizing
Dmitry Makogon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 1 05:11:24 PDT 2021
dmakogon created this revision.
dmakogon added reviewers: mkazantsev, fhahn, reames, skatkov, nikic.
Herald added a subscriber: hiraditya.
dmakogon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Previously in function `getExpectedExitLoopLatchBranch` we considered a block deoptimizing if it had a terminating deoptimize call.
Now updated to it to keep in sync with almost the same logic in LoopPeel (see https://reviews.llvm.org/D110922).
>From that patch:
> Added support for peeling loops with "deoptimizing" exits - such exits that it or any of its children (or any of their children, etc) either has a @llvm.experimental.deoptimize call
> prior to the terminating return instruction of this basic block or is terminated with unreachable. All blocks in the the sequence must have a single successor, maybe except for the > last one.
> Previously we only checked the exit block for being deoptimizing. Now we check if the last reachable block from the exit is deoptimizing.
So now we can consider a block deoptimizing if it meets the condition from the quote.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110924
Files:
llvm/lib/Transforms/Utils/LoopUtils.cpp
Index: llvm/lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -778,8 +778,9 @@
/// Checks if \p L has single exit through latch block except possibly
-/// "deoptimizing" exits. Returns branch instruction terminating the loop
-/// latch if above check is successful, nullptr otherwise.
+/// "deoptimizing" (@llvm.experimental.deoptimize or unreachable-terminated)
+/// exits. Returns branch instruction terminating the loop latch if above check
+/// is successful, nullptr otherwise.
static BranchInst *getExpectedExitLoopLatchBranch(Loop *L) {
BasicBlock *Latch = L->getLoopLatch();
if (!Latch)
@@ -795,8 +796,9 @@
SmallVector<BasicBlock *, 4> ExitBlocks;
L->getUniqueNonLatchExitBlocks(ExitBlocks);
- if (any_of(ExitBlocks, [](const BasicBlock *EB) {
- return !EB->getTerminatingDeoptimizeCall();
+ SmallVector<const BasicBlock *, 8> DeoptimizingBlocks;
+ if (any_of(ExitBlocks, [&](const BasicBlock *EB) {
+ return !IsBlockDeoptimizing(EB, DeoptimizingBlocks);
}))
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110924.376482.patch
Type: text/x-patch
Size: 1178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211001/5d99c5dc/attachment.bin>
More information about the llvm-commits
mailing list