[llvm] [WebAssembly] Incorporate SCCs into WebAssemblyFixIrreducibleControlFlow (PR #181755)

Demetrius Kanios via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 20 16:01:38 PST 2026


================
@@ -18,14 +18,16 @@
 /// The big picture: We recursively process each "region", defined as a group
 /// of blocks with a single entry and no branches back to that entry. A region
 /// may be the entire function body, or the inner part of a loop, i.e., the
-/// loop's body without branches back to the loop entry. In each region we fix
-/// up multi-entry loops by adding a new block that can dispatch to each of the
-/// loop entries, based on the value of a label "helper" variable, and we
-/// replace direct branches to the entries with assignments to the label
-/// variable and a branch to the dispatch block. Then the dispatch block is the
-/// single entry in the loop containing the previous multiple entries. After
-/// ensuring all the loops in a region are reducible, we recurse into them. The
-/// total time complexity of this pass is:
+/// loop's body without branches back to the loop entry. In each region we
+/// identify all the strongly-connected components (SCCs). We fix up multi-entry
+/// loops (SCCs) by adding a new block that can dispatch to each of the loop
+/// entries, based on the value of a label "helper" variable, and we replace
+/// direct branches to the entries with assignments to the label variable and a
+/// branch to the dispatch block. Then the dispatch block is the single entry in
+/// the loop containing the previous multiple entries. Each time we fix some
+/// irreducibility, we recalculate the SCCs. After ensuring all the SCCs in a
+/// region are reducible, we recurse into them. The total time complexity of
+/// this pass is:
 ///
 ///   O(NumBlocks * NumNestedLoops * NumIrreducibleLoops +
 ///     NumLoops * NumLoops)
----------------
QuantumSegfault wrote:

That represents the time complexity of the search itself accurately enough...I think. Though we don't fix EVERY block...just irreducible loops.

I'm not entirely sure why the time complexity was listed there in the first place. But at least this way it definitely looks like progress!

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


More information about the llvm-commits mailing list