summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2019-02-17 15:04:09 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2019-02-17 15:04:09 +0000
commit0f943269a01f0796c59a849f3b38e44154811e51 (patch)
tree48f1f636a1a46b7da9c1e257984232a563533116
parentd37afc92aa522b6078137b8c805728691a13d794 (diff)
downloadbcm5719-llvm-0f943269a01f0796c59a849f3b38e44154811e51.tar.gz
bcm5719-llvm-0f943269a01f0796c59a849f3b38e44154811e51.zip
[NFC] Factor out a function for future reuse
llvm-svn: 354218
-rw-r--r--llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
index 0db5d9e772d..124c55e8ea1 100644
--- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
@@ -90,6 +90,20 @@ static void removeBlockFromLoops(BasicBlock *BB, Loop *FirstLoop,
Current->removeBlockFromLoop(BB);
}
+/// Find innermost loop that is reachable from \p BBs and contains loop \p L.
+static Loop *getInnermostSuccessorLoop(SmallPtrSetImpl<BasicBlock *> &BBs,
+ Loop &L, LoopInfo &LI) {
+ Loop *StillReachable = nullptr;
+ for (BasicBlock *BB : BBs) {
+ Loop *BBL = LI.getLoopFor(BB);
+ if (BBL && BBL->contains(L.getHeader()))
+ if (!StillReachable ||
+ BBL->getLoopDepth() > StillReachable->getLoopDepth())
+ StillReachable = BBL;
+ }
+ return StillReachable;
+}
+
namespace {
/// Helper class that can turn branches and switches with constant conditions
/// into unconditional branches.
@@ -369,14 +383,7 @@ private:
// the current loop. We need to fix loop info accordingly. For this, we
// find the most nested loop that still contains L and remove L from all
// loops that are inside of it.
- Loop *StillReachable = nullptr;
- for (BasicBlock *BB : LiveExitBlocks) {
- Loop *BBL = LI.getLoopFor(BB);
- if (BBL && BBL->contains(L.getHeader()))
- if (!StillReachable ||
- BBL->getLoopDepth() > StillReachable->getLoopDepth())
- StillReachable = BBL;
- }
+ Loop *StillReachable = getInnermostSuccessorLoop(LiveExitBlocks, L, LI);
// Okay, our loop is no longer in the outer loop (and maybe not in some of
// its parents as well). Make the fixup.
OpenPOWER on IntegriCloud