kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

commit 13b62e96a6d28334558d8ed64d924d9e641b9960
parent ab2c6c1f7ad364ce10f2e66f899745e76d4a29b8
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sat, 13 Jun 2026 13:34:19 -0700

doc(plan): record landed O0-codesize levers + deferred frontier (PERF-O0-CODESIZE.md §0)

Diffstat:
Mdoc/plan/PERF-O0-CODESIZE.md | 34+++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/doc/plan/PERF-O0-CODESIZE.md b/doc/plan/PERF-O0-CODESIZE.md @@ -18,7 +18,39 @@ taxes and follow once the aa64 design is proven. --- -## 1. Current state (measured 2026-06-13) +## 0. Landed (branch `o0-codesize`, measured 2026-06-13) + +Five levers landed and gated (determinism + sqlite e2e O0/O1 golden+vs-clang + +toy/parse/smoke-x64/smoke-rv64/dwarf/debug + alloca/far-slot/narrow/p1-x64 +clang-differential probes). **aarch64 sqlite `-O0` `.text`: 455,546 → 398,433 +insns, 1.3291× → 1.1625× tcc (−57,113, half the excess gone).** + +| lever | change | insns | where | +|---|---|--:|---| +| **L2** | 2-insn top-record epilogue (`mov sp,x29; ldp [sp],#16`) | −2,633 | aa64 | +| **L1** | positive-scaled far-slot addressing (Fix B); alloca→x28 anchor | −25,579 | aa64 | +| **L4-P1** | scalar call result stays in the ABI result reg (gated `ndt_result_reg_stable`) | −8,969 `mov` | shared, aa64-on | +| **L4-P2** | copy source materialized straight into the destination register | −16,151 | shared | +| **L3** | elide the zero-extend after a narrow (zero-extending) load | −3,587 | shared | + +The three shared-NDT levers also help other arches for free: **x86-64 sqlite +`.text` −3.18%** (L4-P2 + L3); rv64 likewise (smoke-green). L1/L2 are +aa64-specific (the concept ports, the mechanism does not). L4-P1 is gated to +`ndt_result_reg_stable` arches — aa64 (x0 is call-only-clobbered); **x86-64 is +explicitly excluded** because RAX is an implicit div/mul operand (a result left +there is clobbered before its consumer — caught by the p1-x64 probe). + +**Deferred frontier** (high value, but frontend/CG-API-invasive — left as +follow-ups, not rushed): **L4-P3** args-into-arg-regs (~30 K `mov xK,reg`; needs +a call→arg-producer destination hint threaded through the frontend); +**L3-signed** `ldrsb`/`ldrsh` (~1.3 K; kit's CG integers are sign-agnostic, so +the load can't know it feeds a sign-extend — needs a frontend widening load); +**rv64 L4-P1** (a0 is call-only-clobbered, so sound — pending an on-target +div-after-result check before flipping `ndt_result_reg_stable`). + +--- + +## 1. Original state (measured 2026-06-13, pre-campaign) `build/release/kit cc -c sqlite3.c` vs `tcc -c sqlite3.c`, arm64-macOS, on the 3.50.2 amalgamation (`tmp/projects/sqlite-amalg/sqlite3.c`, 9.28 MB).