diff options
author | Florian Hahn <flo@fhahn.com> | 2023-01-16 12:25:34 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2023-01-16 12:25:34 +0000 |
commit | a6549718d9ba2fdcd14fb8651aeb5000840fa337 (patch) | |
tree | 440dce3a6a2e05a01d260abb4436c01e36fcb876 /llvm/lib/Transforms/Utils/LoopUnroll.cpp | |
parent | 75cb138911debe2966d00d9dd09fd621bfae066e (diff) | |
download | llvm-a6549718d9ba2fdcd14fb8651aeb5000840fa337.zip llvm-a6549718d9ba2fdcd14fb8651aeb5000840fa337.tar.gz llvm-a6549718d9ba2fdcd14fb8651aeb5000840fa337.tar.bz2 |
[LoopUnroll] Don't update DT for changeToUnreachable.
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.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D141810
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnroll.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp index 919a752..cc96d15 100644 --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -756,8 +756,13 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI, } // 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) { |