[llvm] [CodeGenPrepare][NFC] Reland: Update the dominator tree instead of rebuilding it (PR #179040)

Mingjie Xu via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 12 04:02:12 PST 2026


================
@@ -626,39 +637,41 @@ bool CodeGenPrepare::_run(Function &F) {
   // unconditional branch.
   EverMadeChange |= eliminateMostlyEmptyBlocks(F);
 
-  ModifyDT ModifiedDT = ModifyDT::NotModifyDT;
   if (!DisableBranchOpts)
-    EverMadeChange |= splitBranchCondition(F, ModifiedDT);
+    EverMadeChange |= splitBranchCondition(F);
 
   // Split some critical edges where one of the sources is an indirect branch,
   // to help generate sane code for PHIs involving such edges.
   EverMadeChange |=
       SplitIndirectBrCriticalEdges(F, /*IgnoreBlocksWithoutPHI=*/true);
 
+  // Transformations above may invalidate dominator tree and/or loop info.
+  if (EverMadeChange) {
+    DTU->recalculate(F);
+    LI->releaseMemory();
+    LI->analyze(DTU->getDomTree());
+  }
----------------
Enna1 wrote:

Add DT and LI update support for  `bypassSlowDivision()`
eliminateMostlyEmptyBlocks() may introduce new loop, I'm not sure how to handle this with `LoopInfo`.
Add an argument `ResetLI` for eliminateMostlyEmptyBlocks()  indicated that LoopInfo should be recalculated.

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


More information about the llvm-commits mailing list