Skip to content

Commit 3177b92

Browse files
committedAug 29, 2019
[LoopUnroll] Use Lazy strategy for DTU used for MergeBlockIntoPredecessor.
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
1 parent db751c3 commit 3177b92

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎llvm/lib/Transforms/Utils/LoopUnroll.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
870870
assert(!DT || !UnrollVerifyDomtree ||
871871
DT->verify(DominatorTree::VerificationLevel::Fast));
872872

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.