[llvm] ef9446b - [GVN] lazily update dominator tree when merge unconditional branches in function (#88477)

via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 13 20:01:06 PDT 2024


Author: Enna1
Date: 2024-04-14T11:01:02+08:00
New Revision: ef9446bd2d362ec90cd681ae59463d16bf671fe8

URL: https://github.com/llvm/llvm-project/commit/ef9446bd2d362ec90cd681ae59463d16bf671fe8
DIFF: https://github.com/llvm/llvm-project/commit/ef9446bd2d362ec90cd681ae59463d16bf671fe8.diff

LOG: [GVN] lazily update dominator tree when merge unconditional branches in function (#88477)

With this change, the wall time for of GVN pass decreased from
873,745.492 ms to 367,375.304 ms in an our internal testcase.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/GVN.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 67fb2a5da3bb71..86d5c9909f3dc5 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2708,7 +2708,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
   bool Changed = false;
   bool ShouldContinue = true;
 
-  DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
+  DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
   // Merge unconditional branches, allowing PRE to catch more
   // optimization opportunities.
   for (BasicBlock &BB : llvm::make_early_inc_range(F)) {
@@ -2718,6 +2718,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
 
     Changed |= removedBlock;
   }
+  DTU.flush();
 
   unsigned Iteration = 0;
   while (ShouldContinue) {


        


More information about the llvm-commits mailing list