[llvm] r350145 - Drop SE cache early because loop parent can change in LoopSimplifyCFG
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 28 20:26:22 PST 2018
Author: mkazantsev
Date: Fri Dec 28 20:26:22 2018
New Revision: 350145
URL: http://llvm.org/viewvc/llvm-project?rev=350145&view=rev
Log:
Drop SE cache early because loop parent can change in LoopSimplifyCFG
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=350145&r1=350144&r2=350145&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp Fri Dec 28 20:26:22 2018
@@ -87,6 +87,7 @@ private:
Loop &L;
LoopInfo &LI;
DominatorTree &DT;
+ ScalarEvolution &SE;
MemorySSAUpdater *MSSAU;
// Whether or not the current loop has irreducible CFG.
@@ -459,8 +460,9 @@ private:
public:
ConstantTerminatorFoldingImpl(Loop &L, LoopInfo &LI, DominatorTree &DT,
+ ScalarEvolution &SE,
MemorySSAUpdater *MSSAU)
- : L(L), LI(LI), DT(DT), MSSAU(MSSAU) {}
+ : L(L), LI(LI), DT(DT), SE(SE), MSSAU(MSSAU) {}
bool run() {
assert(L.getLoopLatch() && "Should be single latch!");
@@ -507,6 +509,7 @@ public:
return false;
}
+ SE.forgetTopmostLoop(&L);
// Dump analysis results.
LLVM_DEBUG(dump());
@@ -539,6 +542,7 @@ public:
/// Turn branches and switches with known constant conditions into unconditional
/// branches.
static bool constantFoldTerminators(Loop &L, DominatorTree &DT, LoopInfo &LI,
+ ScalarEvolution &SE,
MemorySSAUpdater *MSSAU) {
if (!EnableTermFolding)
return false;
@@ -548,7 +552,7 @@ static bool constantFoldTerminators(Loop
if (!L.getLoopLatch())
return false;
- ConstantTerminatorFoldingImpl BranchFolder(L, LI, DT, MSSAU);
+ ConstantTerminatorFoldingImpl BranchFolder(L, LI, DT, SE, MSSAU);
return BranchFolder.run();
}
@@ -585,7 +589,7 @@ static bool simplifyLoopCFG(Loop &L, Dom
bool Changed = false;
// Constant-fold terminators with known constant conditions.
- Changed |= constantFoldTerminators(L, DT, LI, MSSAU);
+ Changed |= constantFoldTerminators(L, DT, LI, SE, MSSAU);
// Eliminate unconditional branches by merging blocks into their predecessors.
Changed |= mergeBlocksIntoPredecessors(L, DT, LI, MSSAU);
More information about the llvm-commits
mailing list