Skip to content

Commit f9cdb98

Browse files
committed
[LoopUnrollAndJam] Use Lazy strategy for DTU.
We can also apply the earlier updates to the lazy DTU, instead of applying them directly. Reviewers: kuhar, brzycki, asbirlea, SjoerdMeijer Reviewed By: brzycki, asbirlea, SjoerdMeijer Differential Revision: https://reviews.llvm.org/D66918 llvm-svn: 370391
1 parent 11802cc commit f9cdb98

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ LoopUnrollResult llvm::UnrollAndJamLoop(
517517
movePHIs(AftBlocksFirst[It], AftBlocksFirst[0]);
518518
}
519519

520+
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
520521
// Dominator Tree. Remove the old links between Fore, Sub and Aft, adding the
521522
// new ones required.
522523
if (Count != 1) {
@@ -530,15 +531,14 @@ LoopUnrollResult llvm::UnrollAndJamLoop(
530531
ForeBlocksLast.back(), SubLoopBlocksFirst[0]);
531532
DTUpdates.emplace_back(DominatorTree::UpdateKind::Insert,
532533
SubLoopBlocksLast.back(), AftBlocksFirst[0]);
533-
DT->applyUpdates(DTUpdates);
534+
DTU.applyUpdatesPermissive(DTUpdates);
534535
}
535536

536537
// Merge adjacent basic blocks, if possible.
537538
SmallPtrSet<BasicBlock *, 16> MergeBlocks;
538539
MergeBlocks.insert(ForeBlocksLast.begin(), ForeBlocksLast.end());
539540
MergeBlocks.insert(SubLoopBlocksLast.begin(), SubLoopBlocksLast.end());
540541
MergeBlocks.insert(AftBlocksLast.begin(), AftBlocksLast.end());
541-
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
542542
while (!MergeBlocks.empty()) {
543543
BasicBlock *BB = *MergeBlocks.begin();
544544
BranchInst *Term = dyn_cast<BranchInst>(BB->getTerminator());
@@ -555,6 +555,8 @@ LoopUnrollResult llvm::UnrollAndJamLoop(
555555
} else
556556
MergeBlocks.erase(BB);
557557
}
558+
// Apply updates to the DomTree.
559+
DT = &DTU.getDomTree();
558560

559561
// At this point, the code is well formed. We now do a quick sweep over the
560562
// inserted code, doing constant propagation and dead code elimination as we

0 commit comments

Comments
 (0)