code wiki / (root) / _mulcse_minrepro.nx

_mulcse_minrepro.nx source

↩ module page · 32 lines · 1152 B

1// _mulcse_minrepro.nx -- COMPILER DEFECT min-repro (2026-06-10, found by 2// nx_worldgen_tuner_test KAT4 + _ts_diag): in a function whose first 3// statement builds a chained multiply from a PARAM (`grade * lw * lw`), 4// a later `s = s + <call>() * lw` emits <call>*lw*lw -- the doubled 5// multiply chain is wrongly reused (CSE/opt suspected). The all-literal 6// local form does NOT reproduce (T1); the param+call form does (T2). 7// Workaround that compiles right: hoist lw2 = lw*lw and each product 8// into its own `let` (see tl_score in nx_worldgen_tunelib.nx). 9// Exit 0 = compiler correct; exit 1 = T2 miscompile; exit 2 = T1 (new). 10import "nx_syscalls.nx" 11 12func mr_axis() -> i64 { return 16384 } 13 14func mr_score(grade: i64) -> i64 { 15 let lw: i64 = 16385 16 var s: i64 = grade * lw * lw 17 s = s + mr_axis() * lw 18 return s 19} 20 21func main() -> i64 { 22 // T1: all-literal local form (known good) 23 let lw: i64 = 16385 24 var s: i64 = 2 * lw * lw 25 let av: i64 = 16384 26 s = s + av * lw 27 if s != 805388290 { return 2 } 28 29 // T2: param + call form (the live failing shape) 30 if mr_score(2) != 805388290 { return 1 } 31 return 0 32}