From 2d0957ffb117e50522f4b11250d5bd7ee38a8a94 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Sat, 5 Sep 2026 13:21:10 -0600 Subject: [PATCH] =?UTF-8?q?docs(phase-32):=20cookbook=20=C2=A7501-B=20?= =?UTF-8?q?=E2=80=94=20do=20not=20merge=20case=20tails=20in=20C=20(cross-j?= =?UTF-8?q?ump=20merges=20post-alloc;=20a=20C-level=20merge=20deletes=20th?= =?UTF-8?q?e=20reference=20that=20decides=20allocno=20order=20=E2=80=94=20?= =?UTF-8?q?func=5F80039DEC);=20T4b=20row?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/matching-cookbook.md | 15 +++++++++++++++ phase-ends/CURRENT_PHASE.md | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/matching-cookbook.md b/docs/matching-cookbook.md index 7a69c87ff..5cb251f9f 100644 --- a/docs/matching-cookbook.md +++ b/docs/matching-cookbook.md @@ -37173,3 +37173,18 @@ preheader tail is the target's `sll $5,$5,16 / sra $5,$5,16 / move $8,$0`, and r 4. The verdict chain for a wall row: hand pass names the mechanism (done S83), the agent reads the dump the hand pass did not (the `.loop` desirability lines), and the byte gate decides. Cost: one Fable agent, two interruptions by usage limits, the draft written before the first crash — recovered from `.run/P32/t5x/fable/` (write deliverables EARLY, R55). + +**§501-B — DO NOT MERGE CASE TAILS IN C: cross-jump merges them AFTER allocation, and a merge deletes a REFERENCE that decides +global-alloc's order (P32 T4b, `main:func_80039DEC`, a pinned wall banked by a Fable agent).** The row's residual was the raw +copy of the K&R `s16 a2` landing in `$t1` instead of `$a3` (a1's copy in `$t0` in both). Pinned as "fixed by argument +position"; the S83 hand pass guessed a block-local pseudo in `$a3` (global.c `local_reg_n_refs`) — both wrong: that check lives +only in the `best_reg < 0` retry (global.c:1108–1160). **Mechanism (global.c:587–608 `allocno_compare`):** allocnos are ordered by +`floor_log2(n_refs) * n_refs / live_length`; `find_reg` (:960–985) gives the LOWEST free hard reg to whichever allocno comes +first. Every prior draft merged the 0x14/0x28 case tails at C level (`goto L_merge` + a `kind` temp), deleting one `sb a2` — +a2-raw fell to 3 refs / 45 insns (pri 666) and a1-raw (3 / 26, pri 1153) took `$a3` first. The original wrote the natural +`switch (a2)` with the tails DUPLICATED; jump.c cross-jump (:1923) merges them post-reload, so at flow time a2-raw has 4 refs / +41 (`floor_log2(4) = 2` → pri 1951) and is allocated FIRST → `$a3`. Block-scope `u8 *p` per case, no pins, no fences, no +`do { } while (0)`. Verified in `.run/c294/dumps_t5x_9DEC_sw2` (`73 in 8 75 in 7`). Corollaries: (1) a permuter "2" that reads +an uninitialised temp is R63-unsound — its dead pseudo can be the thing occupying the wanted register; (2) when two parm copies +swap registers, compute both allocnos' `n_refs`/`live_length` from the `-dl` dump and ask which SOURCE shape adds or removes a +reference; (3) `docs/gcc-2.7.2-map/regalloc.md` gets the priority formula and the "cross-jump is post-alloc" law. diff --git a/phase-ends/CURRENT_PHASE.md b/phase-ends/CURRENT_PHASE.md index 1f872d4e6..acb487992 100644 --- a/phase-ends/CURRENT_PHASE.md +++ b/phase-ends/CURRENT_PHASE.md @@ -99,7 +99,7 @@ Scale estimate: 3–5 sessions. `func_80011380` → `.run/m3/opus/func_80011380.c`; `func_801834A4` → `.run/S71_gate14/ov_SC03_105*/`), `exclude_audit --write`, `backlog.py render`; a T3 idiom naming a wall's mechanism re-opens that row (bounded: one attempt, permuter first). Wall table into this file; cookbook §496+; decision log; accelerators. -- [ ] **T4b — crack and bank the final 15 (ADDED 2026-09-05 by Drew's directive, supersedes the kill gate: "anything that isn't the original hand-written asm or the PsyQ libs needs to be cracked and banked before we finish"; "before you spawn Fable agents, hand crack each and figure out the blocker to fix it")** (xHigh→Max recommended; Fable agents authorised AFTER the hand pass): for each of the 15 rows (8 NEAR + 7 walls) the coordinator hand-cracks — read the diff + the recorded mechanism, read the compiler (dumps + source), find the lever the record did not try, measure, bank through the verified chain (rtu in the real TU → bank.sh / gate_main) — and only then hands the leftovers to one Fable agent each (brief `.run/P32/t5x/BRIEF.md`). Plumbing landed first: `src/800_c.c` decl/extern edits byte-neutral (this commit). Work dirs `.run/P32/t4b//`. **Hand pass DONE 2026-09-05 (S83): all 15 rows read against their diffs and the compiler; 22 spellings measured (all regressions), 0 banks; every row's blocker refined to a named mechanism with the untried lever written in `.run/P32/t4b//NOTES.md` (func_80032A74: the transient caller-save area — reload1.c order proven; func_8017DF28: the block-move pseudo reuse vs reorg's branch-target hoist; func_80011380: the target's assignment shape; func_801834A4: sign-hoist vs const-hoist thresholds; …). TU plumbing for func_80039DEC/func_800391D4 committed byte-neutral (`commit:3953`). 15 Fable agents launched ~13:05 MDT (two usage-limit outages, resumed each time via SendMessage). **T4b (1): `main:func_800391D4` BANKED 143dbb89 (`commit:3956`) — a pinned wall: explicit promotion + insn_count pads 7→9 (§501); pin dropped (6 remain).** Remaining 14 in flight.** +- [ ] **T4b — crack and bank the final 15 (ADDED 2026-09-05 by Drew's directive, supersedes the kill gate: "anything that isn't the original hand-written asm or the PsyQ libs needs to be cracked and banked before we finish"; "before you spawn Fable agents, hand crack each and figure out the blocker to fix it")** (xHigh→Max recommended; Fable agents authorised AFTER the hand pass): for each of the 15 rows (8 NEAR + 7 walls) the coordinator hand-cracks — read the diff + the recorded mechanism, read the compiler (dumps + source), find the lever the record did not try, measure, bank through the verified chain (rtu in the real TU → bank.sh / gate_main) — and only then hands the leftovers to one Fable agent each (brief `.run/P32/t5x/BRIEF.md`). Plumbing landed first: `src/800_c.c` decl/extern edits byte-neutral (this commit). Work dirs `.run/P32/t4b//`. **Hand pass DONE 2026-09-05 (S83): all 15 rows read against their diffs and the compiler; 22 spellings measured (all regressions), 0 banks; every row's blocker refined to a named mechanism with the untried lever written in `.run/P32/t4b//NOTES.md` (func_80032A74: the transient caller-save area — reload1.c order proven; func_8017DF28: the block-move pseudo reuse vs reorg's branch-target hoist; func_80011380: the target's assignment shape; func_801834A4: sign-hoist vs const-hoist thresholds; …). TU plumbing for func_80039DEC/func_800391D4 committed byte-neutral (`commit:3953`). 15 Fable agents launched ~13:05 MDT (two usage-limit outages, resumed each time via SendMessage). **T4b (1): `main:func_800391D4` BANKED 143dbb89 (`commit:3956`) — a pinned wall: explicit promotion + insn_count pads 7→9 (§501); pin dropped. **T4b (2): `main:func_80039DEC` BANKED 143dbb89 (`commit:3959`) — a pinned wall: the natural switch with duplicated tails, so a2's raw copy keeps 4 refs and wins $a3 (§501-B); pins 7 → 5.** Remaining 13 in flight.** - [ ] **T5 — PhaseEnd** (Max, Tier 1 — prompt R27): P7 checkbox walk; milestone demo (R22 fleet N/N, tools-health, `verbatim_check --strict`, final census, wall ledger, parked-5 dispositions via `make audit-disc`, `make report` all three metrics + main `143dbb89…` with/without SDK dirs, corrected denominators); **WAIT