code wiki / _hdl_build / nx_superopt_governed_test.nx
nx_superopt_governed_test.nx
buildroot/runtime/_hdl_build/nx_superopt_governed_test.nx
about
nx_superopt_governed_test.nx -- a SECOND GENERATOR in the governed cycle: the
superoptimizer. Unlike the rewrite-rule author, this generator SEARCHES (e-graph
saturation) for a strictly-cheaper EQUIVALENT program and the loop governs the
result -- so the loop now authors OPTIMIZATIONS, not just identities.
GENERATOR build seed (mul x 8), saturate, emit the cost-minimal DAG (shl x 3)
VERIFIER the emitted candidate must EVALUATE equal to the seed over a battery
(nx_superopt_eval_emit) -- proven equivalent, not assumed
COUNCIL verifies = equivalent ; worth = strictly cheaper (cost decreased) ;
3->2->1 -> ABSORB the optimization, else escalate
NEG-CTRL a WRONG candidate (shl x 2 = x*4 != x*8) is NOT equivalent -> refused
Known answer: the real optimization is ABSORBED, the negative control REFUSED;
exit 0 iff governed correctly.
dependencies 2 imports · 0 importers
imports: nx_superopt.nxnx_crew_council.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
| 19 | const SOG_W: i64 = 16 |
functions
| 22 | func sog_equiv(cand_out: *NxEmitNode, cand_n: i64, cand_root: i64) -> i64 |
| 35 | func main() -> i64 |