Parent: #459 Depends on: #467, #461
Goal
Implement backend-neutral global optimizations over the optimizer IR: redundant work elimination, loop optimization, range reasoning, and guard/bounds-check reduction.
Scope
- Global value numbering/CSE, copy propagation, sparse conditional constant propagation, dead-code elimination, and effect-aware load/store forwarding.
- Dominator-based loop-invariant code motion, induction-variable recognition, strength reduction, loop rotation/unswitching where profitable, and invariant guard hoisting.
- Integer/range/length analysis for overflow-aware arithmetic, packed arrays, strings, typed arrays, and Wasm memory.
- Redundant shape/prototype/tag/bounds/barrier elimination only when invalidation and memory-order proofs remain valid.
- Block layout, branch probability, register-pressure, and code-size cost models.
- Preserve exact bytecode-step/watchdog accounting even when emitted machine operations are removed or moved.
Effect model requirements
Calls, coercions, getters/setters, proxies, iterators, allocation/OOM, GC safepoints, debugger hooks, atomics, shared-memory accesses, and no-GIL mutations must be explicit barriers or modeled effects. Unknown does not mean pure.
Acceptance
- An IR verifier checks dominance, SSA, effect ordering, recovery states, and map liveness after every pass in test builds.
- Each pass has focused positive/negative tests and seeded forced-off/on semantic differentials.
- Moving GC, exceptions, invalidation races, termination, exact steps, atomics, and host effects remain exact.
- #461 reports pass-level compile time, code bytes, eliminated operations/guards, and deopt changes.
- Retained passes improve at least one predeclared #460 row without a noise-qualified regression elsewhere.
Foundation
Optimizer CFG/SSA and reducible regions landed under #431 and #438, including a42aaf26.