fitzgen opened PR #13688 from fitzgen:branch-to-trap-in-egraph-pass to bytecodealliance:main:
The last thing that the legalization pass did was branch-to-trap optimization, where a conditional branch to a block that just unconditionally traps was replaced with a
trapzortrapnz. This commit moves this optimization into the egraph pass via:
Making the branch-to-trap analysis compute its results for a given block on-demand (and memoize its results) so that traversal order doesn't matter.
Adding a
SimplifySkeletonInst::ReplaceWithTwovariant to replace a skeleton instruction with two other instructions.Adding two new
simplify_skeletonISLE rules that use results from the branch-to-trap analysis and theReplaceWithTwovariant to perform the rewrite.The legalizer and its filetest infrastructure is completely removed.
<!--
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 #13688.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13688.
fitzgen requested wasmtime-core-reviewers for a review on PR #13688.
fitzgen updated PR #13688.
:thumbs_up: cfallin submitted PR review:
Looks great -- thanks!
cfallin added PR #13688 Cranelift: Fold branch-to-trap optimization into the egraphs pass to the merge queue.
:check: cfallin merged PR #13688.
cfallin removed PR #13688 Cranelift: Fold branch-to-trap optimization into the egraphs pass from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC