Skip to content

Commit

Permalink
[GVN] lazily update dominator tree when merge unconditional branches …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Enna1 authored Apr 14, 2024
1 parent fad3752 commit ef9446b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/GVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -2718,6 +2718,7 @@ bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,

Changed |= removedBlock;
}
DTU.flush();

unsigned Iteration = 0;
while (ShouldContinue) {
Expand Down

0 comments on commit ef9446b

Please sign in to comment.