[llvm] r345820 - [NFC] Reorganize code to prepare it for more transforms
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 1 02:42:50 PDT 2018
Author: mkazantsev
Date: Thu Nov 1 02:42:50 2018
New Revision: 345820
URL: http://llvm.org/viewvc/llvm-project?rev=345820&view=rev
Log:
[NFC] Reorganize code to prepare it for more transforms
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp?rev=345820&r1=345819&r2=345820&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Thu Nov 1 02:42:50 2018
@@ -41,8 +41,8 @@ using namespace llvm;
#define DEBUG_TYPE "loop-simplifycfg"
-static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI,
- ScalarEvolution &SE, MemorySSAUpdater *MSSAU) {
+static bool mergeBlocksIntoPredecessors(Loop &L, DominatorTree &DT,
+ LoopInfo &LI, MemorySSAUpdater *MSSAU) {
bool Changed = false;
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
// Copy blocks into a temporary array to avoid iterator invalidation issues
@@ -63,13 +63,24 @@ static bool simplifyLoopCFG(Loop &L, Dom
// Merge Succ into Pred and delete it.
MergeBlockIntoPredecessor(Succ, &DTU, &LI, MSSAU);
- SE.forgetTopmostLoop(&L);
-
Changed = true;
}
return Changed;
}
+
+static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI,
+ ScalarEvolution &SE, MemorySSAUpdater *MSSAU) {
+ bool Changed = false;
+
+ // Eliminate unconditional branches by merging blocks into their predecessors.
+ Changed |= mergeBlocksIntoPredecessors(L, DT, LI, MSSAU);
+
+ if (Changed)
+ SE.forgetTopmostLoop(&L);
+
+ return Changed;
+}
PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR,
More information about the llvm-commits
mailing list