code wiki / (root) / nx_eqsat_vs_gcc_battery_test.nx

nx_eqsat_vs_gcc_battery_test.nx

buildroot/runtime/nx_eqsat_vs_gcc_battery_test.nx

8200 B178 linesdepth 7pulls 9 transitivereach 0 importersview sourcekind gate/prooftopic eqsat
docsdependenciesstructsconstsfunctions

about

nx_eqsat_vs_gcc_battery_test.nx -- FAIR apples-to-apples op-count battery for the e-graph optimizer vs gcc -O3 (incumbent oracle, same box). METRIC (stated explicitly): ARITHMETIC OPERATION COUNT of the optimized straight-line computation. We count DISTINCT arithmetic nodes in the emitted DAG (op != CONST, op != VAR), i.e. each shared subexpression once -- the SAME thing one counts in gcc's asm (add/sub/imul/lea-scale/shl/ shr/sar/and/or/xor/not/neg in the function body, excluding prologue/ epilogue/reg-moves/ret). This is NOT the recursive class_cost (which double-counts shared children and would UNFAIRLY inflate our number). NON-CHERRY-PICKED: a fixed battery declared up front; every kernel reported whatever the verdict (no dropping losers). Each kernel expresses the SAME computation we hand to gcc in battery.c. Output per kernel: "<id> <emit_total> <arith_ops> <cost> <root_op> <sat>" arith_ops is the FAIR metric. cost is class_cost (context only). sat is the saturate status (4=SATURATED/fixpoint, 5=hit-budget; extraction is sound either way -- costs only decrease, so budget exhaustion is not an error).

dependencies 1 imports · 0 importers

nx_eqsat.nx nx_eqsat_vs_gcc_battery_test.n

imports: nx_eqsat.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main _fresh nx_eqsat_init nx_eqsat_enable_constfold sys_mmap 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 ↻

structs

none

consts

none

functions

23func _emit_num(v: i64) -> i64
called by 1: _report
31func _nl() -> i64 { let z: *u8 = sys_mmap(2); z[0] = 10; sys_write(1, z, 1); return 0 }
called by 1: _report
34func _emit_eq(out: *NxEmitNode, i: i64, j: i64) -> i64
called by 2: _emit_eq_arith_ops calls 1: _emit_eq
51func _arith_ops(out: *NxEmitNode, cnt: i64) -> i64
called by 1: _report calls 1: _emit_eq
76func _report(id: i64, g: *NxEGraph, root: i64) -> i64
100func _fresh(g_out: *i64) -> *NxEGraph
111func main() -> i64