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

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 23:38:26 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Enna1 (Enna1)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/88477.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/GVN.cpp (+2-1) 


``````````diff
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) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/88477


More information about the llvm-commits mailing list