nx_cascade_test.nx
buildroot/runtime/nx_cascade_test.nx
about
nx_cascade_test.nx -- regression test for the parallel-copy
semantic violation bug in nxc2's copy-forward pass.
Bug: copy-forward in opt.c walked through single-def OP_COPY
chains into multi-def merge values, breaking the cascade emitted
by mem2reg's out-of-SSA pass at end of loop bodies. Source
while c { h=g; g=f; ...; b=a; a=99 }
compiled to
mv a, 99 # writes a first
mv b, a # b gets NEW a, not OLD a
... cascade collapsed
Fixed 2026-05-17 in opt.c::opt_copy_forward_function by skipping
forwarding for OP_COPY whose result is multi-def (i.e., parallel-
copy glue at end of BB). This file must keep passing.
This test covers FOUR cascade shapes:
T1: 8-var right-rotation (the original failing case)
T2: 3-var swap (a, b, c rotate)
T3: single-var redefine (a = a + 1)
T4: pair-wise swap via temp (a/b swap)
expect_exit: 0
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| none |
functions
| 28 | func main() -> i64 |