[llvm] r370292 - [LoopUnroll] Use Lazy strategy for DTU used for MergeBlockIntoPredecessor.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 21:26:29 PDT 2019


Author: fhahn
Date: Wed Aug 28 21:26:29 2019
New Revision: 370292

URL: http://llvm.org/viewvc/llvm-project?rev=370292&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp

Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=370292&r1=370291&r2=370292&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Wed Aug 28 21:26:29 2019
@@ -870,7 +870,7 @@ LoopUnrollResult llvm::UnrollLoop(Loop *
   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());
@@ -890,6 +890,8 @@ LoopUnrollResult llvm::UnrollLoop(Loop *
       }
     }
   }
+  // 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.




More information about the llvm-commits mailing list