Skip to content

Commit

Permalink
[LoopUnrollAndJam] Use Lazy strategy for DTU.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fhahn committed Aug 29, 2019
1 parent 11802cc commit f9cdb98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ LoopUnrollResult llvm::UnrollAndJamLoop(
movePHIs(AftBlocksFirst[It], AftBlocksFirst[0]);
}

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

// Merge adjacent basic blocks, if possible.
SmallPtrSet<BasicBlock *, 16> MergeBlocks;
MergeBlocks.insert(ForeBlocksLast.begin(), ForeBlocksLast.end());
MergeBlocks.insert(SubLoopBlocksLast.begin(), SubLoopBlocksLast.end());
MergeBlocks.insert(AftBlocksLast.begin(), AftBlocksLast.end());
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
while (!MergeBlocks.empty()) {
BasicBlock *BB = *MergeBlocks.begin();
BranchInst *Term = dyn_cast<BranchInst>(BB->getTerminator());
Expand All @@ -555,6 +555,8 @@ LoopUnrollResult llvm::UnrollAndJamLoop(
} else
MergeBlocks.erase(BB);
}
// Apply updates to the DomTree.
DT = &DTU.getDomTree();

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

0 comments on commit f9cdb98

Please sign in to comment.