What problem does it solve?
Writing tests for SSA optimization passes in the Noir compiler often stops at snapshot assertions, which pin output shape but cannot catch miscompilations where the pass silently changes what the program computes. This Skill guides you to write tests that prove a pass preserves execution semantics, not just structure.
Core Features & Use Cases
- Semantics-preserving assertions: Use
assert_pass_does_not_affect_execution to interpret SSA before and after a pass and assert identical results, including failure behavior like which constraint fails.
- Snapshot and no-op testing: Pin transformed SSA output with
assert_ssa_snapshot!, or assert a pass leaves input untouched with assert_ssa_does_not_change.
- Realistic test inputs: Generate real SSA from Noir programs via
nargo compile --show-ssa-pass, build interpreter inputs with Value constructors, and handle path-sensitive bugs with one run per input.
- Use Case: When fixing a loop-invariant-code-motion miscompilation, write a regression test that runs the interpreter on both control-flow paths, asserts the specific
ConstrainEqFailed error is preserved, and snapshots the transformed SSA.
Quick Start
Ask the AI to write a regression test for an SSA pass in compiler/noirc_evaluator/src/ssa/opt/ that proves the pass preserves execution semantics and snapshots its output.