You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eliminates conditions implied false by dominating guards. When a loop guard proves `i < bound`, any inner condition `i >= bound` is known false and can be replaced with `false`. The existing `const_branch_prune` pass then removes the dead branch on the next iteration.
123
+
124
+
Also handles dominating if-conditions: when `if (var + offset) < bound { ... }`, bounds checks `(var + k) >= bound` for `k <= offset` inside the then-block are known false.
125
+
126
+
This subsumes the former WIR-level bounds check elimination pass, handling both strict `<` and inclusive `<=` guard patterns at the TIR level.
Hoists the backing array allocation for template strings out of loops. Each iteration reuses the same backing array buffer. Escape analysis ensures the template result is not stored beyond the iteration.
@@ -145,6 +154,7 @@ WIR-level optimizations run after WIR build and before Wasm emission, operating
145
154
### Phase 1: Type Representation
146
155
147
156
-**Nullable ref optimization** — rewrites type-level representations for nullable references
157
+
-**Pre-SROA copy propagation** — inlines trivial copies like `alias = source` so that SROA can see direct variant access patterns (RefTest/RefCast on source)
148
158
-**Multi-value return SROA** — rewrites functions returning small scalar structs (2–4 fields) to use Wasm multi-value returns, eliminating GC struct allocation at function boundaries
149
159
-**Single-field parameter SROA** — rewrites `ref null S` parameters (where `S` is a single-field struct) to take the scalar field value directly. Primary trigger is `Box<T>` from template string interpolation.
150
160
@@ -155,8 +165,7 @@ After parameter SROA, substitutes `StructGet(LocalGet(x), field)` with the inner
-**Forward struct field constants** — tracks known field values (constants and `LocalGet` references) through `StructGet` for bounds check elimination. Also resolves block-result `StructNew` patterns for single-exit blocks. Uses stores-aware alias analysis: locals passed to functions without `stores` declarations are not marked as aliased, enabling field forwarding even when references are passed to callees
159
-
-**Eliminate loop-guarded bounds checks** — removes redundant `index >= bound` checks when the loop guard dominates them. Supports both `i < bound` (strict) and `i <= limit` (inclusive) guards. For inclusive guards, resolves definition chains to verify that the bounds check bound equals `limit + 1` (e.g., `arr.used == limit + 1` when `arr = Array::filled(limit + 1, ...)`)
168
+
-**Forward struct field constants** — tracks known field values (constants and `LocalGet` references) through `StructGet` for constant index bounds check elimination. Also resolves block-result `StructNew` patterns for single-exit blocks. Uses stores-aware alias analysis: locals passed to functions without `stores` declarations are not marked as aliased, enabling field forwarding even when references are passed to callees
160
169
161
170
### Phase 4: Library-Specific Rewrites
162
171
@@ -201,7 +210,7 @@ After parameter SROA, substitutes `StructGet(LocalGet(x), field)` with the inner
201
210
-**Reassociation** — reorder associative operations to group constants
202
211
-**SimplifyCFG** — general control flow graph simplification
203
212
-**Tail Call Optimization** — emit `return_call` for tail-recursive calls
0 commit comments