fitzgen opened PR #13922 from fitzgen:rebuild-cfg-only-when-needed to bytecodealliance:main:
Previously, the egraph pass unconditionally recomputed the CFG, determined reachability via a DFS traversal, and eliminated unreachable code after its optimize loop. It did this to clean up blocks that branch simplification may have made unreachable. But a block's successor set (and hence reachability) can only change when a terminator is rewritten, and that doesn't happen on many functions.
This commit adds tracking of whether any skeleton simplification rewrote a block terminator and skips the CFG rebuild, reachability computation, and dead-code elimination entirely when no block terminator was rewritten.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
fitzgen requested cfallin for a review on PR #13922.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13922.
:thumbs_up: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Rather than threading through a flag (and returning a bool, which is always a bit ambiguous), could we have a helper
SkeletonInstSimplification::rewrites_terminator()that's a simple exhaustive match-predicate, thencfg_maybe_changed |= cmd.rewrites_terminator();at the callsite above?
fitzgen updated PR #13922.
fitzgen has enabled auto merge for PR #13922.
fitzgen added PR #13922 Cranelift: skip CFG rebuild in egraph pass when no terminator changed to the merge queue.
github-merge-queue[bot] removed PR #13922 Cranelift: skip CFG rebuild in egraph pass when no terminator changed from the merge queue.
fitzgen added PR #13922 Cranelift: skip CFG rebuild in egraph pass when no terminator changed to the merge queue.
:check: fitzgen merged PR #13922.
fitzgen removed PR #13922 Cranelift: skip CFG rebuild in egraph pass when no terminator changed from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC