[PATCH] D141810: [LoopUnroll] Don't update DT for changeToUnreachable.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 15 15:46:28 PST 2023
fhahn created this revision.
fhahn added reviewers: nikic, reames, mkazantsev, asbirlea, kuhar.
Herald added subscribers: StephenFan, zzheng, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: LLVM.
There is no need to update the DT here, because there must be a unique
latch. Hence if the latch is not exiting it must directly branch back
to the original loop header and does not dominate any nodes.
Skipping a DT update here simplifies D141487 <https://reviews.llvm.org/D141487>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141810
Files:
llvm/lib/Transforms/Utils/LoopUnroll.cpp
Index: llvm/lib/Transforms/Utils/LoopUnroll.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -756,8 +756,13 @@
}
// When completely unrolling, the last latch becomes unreachable.
- if (!LatchIsExiting && CompletelyUnroll)
- changeToUnreachable(Latches.back()->getTerminator(), PreserveLCSSA, &DTU);
+ if (!LatchIsExiting && CompletelyUnroll) {
+ // There is no need to update the DT here, because there must be a unique
+ // latch. Hence if the latch is not exiting it must directly branch back to
+ // the original loop header and does not dominate any nodes.
+ assert(LatchBlock->getSingleSuccessor() && "Loop with multiple latches?");
+ changeToUnreachable(Latches.back()->getTerminator(), PreserveLCSSA);
+ }
// Merge adjacent basic blocks, if possible.
for (BasicBlock *Latch : Latches) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141810.489404.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230115/01dc3e16/attachment.bin>
More information about the llvm-commits
mailing list