code wiki / _hdl_build / nx_race_native_opt.nx
nx_race_native_opt.nx
buildroot/runtime/_hdl_build/nx_race_native_opt.nx
about
nx_race_native_opt.nx -- "OURS, OPTIMIZED": the SAME MINSTD LCG as nx_race_native, but with the
mod-by-(2^31-1) DIVIDE replaced by MERSENNE STRENGTH-REDUCTION (shifts/adds) -- exactly the optimization
gcc -O2 applies automatically. Since 2^31 == 1 (mod 2^31-1), p mod (2^31-1) = fold the 31-bit halves.
PURPOSE: prove the measured ~1.7x Nishi-vs-gcc-O2 gap is PURELY auto-strength-reduction (nx_cc doesn't do
it yet) -- when the optimization is expressed, Nishi's sovereign codegen reaches the optimizing-gcc frontier.
MUST print 668950819 (identical to the divide version) or the reduction is wrong. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 8 | const K_MAGIC_50000000: i64 = 50000000 |
| 9 | const K_MAGIC_48271: i64 = 48271 |
| 10 | const K_MAGIC_2147483647: i64 = 2147483647 |
functions
| 11 | func putn(v: i64) -> i64 |
| 24 | func main() -> i64 |