Skip to content

Commit

Permalink
[LoopUnroll] Use Lazy strategy for DTU used for MergeBlockIntoPredece…
Browse files Browse the repository at this point in the history
…ssor.

We do not access the DT in the loop, so we do not have to apply updates
eagerly. We can apply them lazyly and flush them after we are done
merging blocks.

As follow-up work, we might be able to use the DTU above as well,
instead of manually updating the DT.

This brings the example from PR43134 from ~100s to ~4s for a relase +
assertions build on my machine.

Reviewers: efriedma, kuhar, asbirlea, brzycki

Reviewed By: kuhar, brzycki

Differential Revision: https://reviews.llvm.org/D66911

llvm-svn: 370292
  • Loading branch information
fhahn committed Aug 29, 2019
1 parent db751c3 commit 3177b92
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/Transforms/Utils/LoopUnroll.cpp
Expand Up @@ -870,7 +870,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
assert(!DT || !UnrollVerifyDomtree ||
DT->verify(DominatorTree::VerificationLevel::Fast));

DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
// Merge adjacent basic blocks, if possible.
for (BasicBlock *Latch : Latches) {
BranchInst *Term = dyn_cast<BranchInst>(Latch->getTerminator());
Expand All @@ -890,6 +890,8 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
}
}
}
// Apply updates to the DomTree.
DT = &DTU.getDomTree();

// At this point, the code is well formed. We now simplify the unrolled loop,
// doing constant propagation and dead code elimination as we go.
Expand Down

0 comments on commit 3177b92

Please sign in to comment.