code wiki / _hdl_build / nx_superopt_governed_test.nx

nx_superopt_governed_test.nx

buildroot/runtime/_hdl_build/nx_superopt_governed_test.nx

5811 B111 linesdepth 8pulls 13 transitivereach 0 importersview sourcekind gate/prooftopic superopt
docsdependenciesstructsconstsfunctions

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

nx_superopt.nx nx_crew_council.nx nx_superopt_governed_test.nx

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

main cc_puts sys_write nx_eqsat_init nx_eqsat_add_var nx_eqsat_add nx_eqsat_op_is_valid nx_eqsat_arity_for nx_cf_intern_const nx_eqsat_add_const nx_eqsat_add ↻ nx_eqsat_mix nx_cf_make_const_node nx_eqsat_new_class nx_eqsat_find nx_eqsat_find ↻ nx_eqsat_fold_value nx_eqsat_op_to_gate_kind nx_gsim_kind_supported nx_eqsat_arity_for ↻ nx_eqsat_find ↻ nx_gsim_eval_cell nx_eqsat_op_cost nx_eqsat_new_class ↻ nx_eqsat_union_cited nx_eqsat_find ↻ nx_eqsat_log_rule nx_eqsat_push_dirty nx_eqsat_fingerprint nx_eqsat_mix ↻ nx_hmap_has nx_hmap_probe_find nx_hmap_hash nx_hmap_entry_at nx_hmap_get nx_hmap_probe_find ↻ nx_hmap_entry_at ↻ nx_eqsat_node_matches nx_eqsat_arity_for ↻ nx_eqsat_find ↻

structs

none

consts

19const SOG_W: i64 = 16

functions

22func sog_equiv(cand_out: *NxEmitNode, cand_n: i64, cand_root: i64) -> i64
called by 1: main calls 1: nx_superopt_eval_emit
35func main() -> i64