Loop &L;
LoopInfo &LI;
DominatorTree &DT;
+ ScalarEvolution &SE;
MemorySSAUpdater *MSSAU;
// Whether or not the current loop has irreducible CFG.
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!");
return false;
}
+ SE.forgetTopmostLoop(&L);
// Dump analysis results.
LLVM_DEBUG(dump());
/// 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;
if (!L.getLoopLatch())
return false;
- ConstantTerminatorFoldingImpl BranchFolder(L, LI, DT, MSSAU);
+ ConstantTerminatorFoldingImpl BranchFolder(L, LI, DT, SE, MSSAU);
return BranchFolder.run();
}
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);