Context
PR #53 eliminated the has_unsupported_isle_instructions skip block — all standard WASM instructions are now wired into the ISLE pipeline. However, functions containing BrIf or BrTable are still skipped by has_dataflow_unsafe_control_flow for the two term-rewriting passes (optimize_term_rewriting and optimize_advanced_instructions).
Problem
The ISLE dataflow optimization (simplify_with_env) can incorrectly move side effects outside of control flow blocks. For example, a LocalSet after a BrIf may be moved to execute unconditionally — a semantic violation.
This means functions with conditional branches don't get term-rewriting optimizations (constant propagation through locals, redundant load elimination, etc.), even though they now get all other passes (DCE, branch simplification, code folding, etc.).
Solution
Make the dataflow analysis control-flow aware:
- Track which values are defined inside conditional blocks
- Don't propagate
LocalSet values across branch boundaries
- Consider using dominator tree analysis to determine safe propagation points
- Or: split the function into basic blocks and optimize each independently
Files
loom-core/src/lib.rs: has_dataflow_unsafe_control_flow (line ~6654), optimize_term_rewriting (line ~6689), optimize_advanced_instructions (line ~10700)
Impact
This is the last major optimization coverage gap. Removing this restriction would give every function full optimization, not just functions without conditional branches.
Context
PR #53 eliminated the
has_unsupported_isle_instructionsskip block — all standard WASM instructions are now wired into the ISLE pipeline. However, functions containingBrIforBrTableare still skipped byhas_dataflow_unsafe_control_flowfor the two term-rewriting passes (optimize_term_rewritingandoptimize_advanced_instructions).Problem
The ISLE dataflow optimization (
simplify_with_env) can incorrectly move side effects outside of control flow blocks. For example, aLocalSetafter aBrIfmay be moved to execute unconditionally — a semantic violation.This means functions with conditional branches don't get term-rewriting optimizations (constant propagation through locals, redundant load elimination, etc.), even though they now get all other passes (DCE, branch simplification, code folding, etc.).
Solution
Make the dataflow analysis control-flow aware:
LocalSetvalues across branch boundariesFiles
loom-core/src/lib.rs:has_dataflow_unsafe_control_flow(line ~6654),optimize_term_rewriting(line ~6689),optimize_advanced_instructions(line ~10700)Impact
This is the last major optimization coverage gap. Removing this restriction would give every function full optimization, not just functions without conditional branches.