mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-29 15:18:24 -04:00
docs(cookbook): §353 -fno-thread-jumps as a pass-identification oracle; launder the value to keep a dead re-test
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
> **Generated by `tools/cookbook_index.py` — do not hand-edit** (R33). Regenerate after adding a cookbook section.
|
||||
>
|
||||
> `docs/matching-cookbook.md` is ~716 KB / 1003 sections. Grepping it blind is how three P30 wave-1 agents each "discovered" an idiom that was already written down. **Start here, then read the section.** A section appears under every symptom it addresses.
|
||||
> `docs/matching-cookbook.md` is ~716 KB / 1004 sections. Grepping it blind is how three P30 wave-1 agents each "discovered" an idiom that was already written down. **Start here, then read the section.** A section appears under every symptom it addresses.
|
||||
|
||||
**How to use:** name what you SEE in the diff (a stolen delay slot, an extra `la`, a swapped register pair, a `conflicting types` error), find that symptom below, read those sections first. If nothing fits, THEN grind — and add a section when you win.
|
||||
|
||||
@@ -937,7 +937,7 @@
|
||||
- **§324** — THE ARITY-SELF WALL NEEDS *BOTH* HALVES: A K&R DEFINITION **AND** A NO-PROTO TU DECL; EITHER ALONE STILL FAILS (P31 S67; rtu-proven ov_SC01_005/func_8017FBCC, 14 instances measured) <sub>L30949</sub>
|
||||
- **§337** — THE CC1-ONLY BLOCKER CLASS: `blocker_probe`'s STATIC ORACLE REPORTS "none" AND THE WHOLE-TU COMPILE STILL FAILS (P31 S67; ov_SC04_011/func_801827DC, md_MAIN_027/func_800CB4A4) <sub>L31157</sub>
|
||||
|
||||
### build graph, splat & the harness (181)
|
||||
### build graph, splat & the harness (182)
|
||||
|
||||
- **§4** — Flag/toolchain gotchas <sub>L190</sub>
|
||||
- **Build** — mechanism — per-file opt override (splat resegmentation) <sub>L307</sub>
|
||||
@@ -1120,6 +1120,7 @@
|
||||
- **§337** — THE CC1-ONLY BLOCKER CLASS: `blocker_probe`'s STATIC ORACLE REPORTS "none" AND THE WHOLE-TU COMPILE STILL FAILS (P31 S67; ov_SC04_011/func_801827DC, md_MAIN_027/func_800CB4A4) <sub>L31157</sub>
|
||||
- **§340** — §194-K COROLLARY: **FLIP THE FALSE EDGE YOU CANNOT DELETE.** A "scheduler" residual can be sched.c's ALIAS ORACLE emitting a FALSE true-dependence; source order chooses its DIRECTION (P31 S67; byte-proven ov_SC03_107/func_8017CF48, 10 -> 0 in one compile, zero bytes) <sub>L31209</sub>
|
||||
- **§346** — `c ? X : -X` TAKES expand_expr's COND_EXPR **SINGLETON** PATH (copy, then negate IN PLACE) — AN if/else STATEMENT GIVES THE TWO-ARM FORM (P31 S67; byte-proven ov_SC03_102/func_80180C38, closed the last instruction) <sub>L31322</sub>
|
||||
- **§353** — USE `-fno-thread-jumps` AS AN **ORACLE** TO PROVE A RESIDUAL IS thread_jumps, THEN LAUNDER THE *VALUE* TO KEEP A DEAD RE-TEST (P31 S67; byte-proven ov_SC01_008/func_8017EC68, 279 ins) <sub>L31519</sub>
|
||||
|
||||
### process, measurement & doctrine (122)
|
||||
|
||||
@@ -2553,6 +2554,7 @@
|
||||
- **§350** — A ZERO-BYTE RE-TIE SETS `reg_n_sets=2`, WHICH KILLS sched1's `birthing_insn_p` LAUNCH_PRIORITY BOOST — THE MECHANISM BEHIND "MY ADDS ARE GLUED TO THEIR STORES" (P31 S67; byte-proven ov_SC04_011/func_80180B24, 215 ins) <sub>L31435</sub>
|
||||
- **§351** — `/s` (MEM_IN_STRUCT_P) IS A DIAL YOU CHOOSE PER ACCESS: A COMPONENT_REF GRANTS IT AND LETS cse KEEP AN INDEX ACROSS THE STORE; A PLAIN CAST DENIES IT (P31 S67; ov_SC01_000/func_8017DD04, 186 -> 5) <sub>L31456</sub>
|
||||
- **§352** — ⚠ TWO IDENTICAL `__asm__ __volatile__("")` BARRIERS **MERGE WITH EACH OTHER** — SPELL THE SECOND ONE DIFFERENTLY (P31 S67; byte-proven resident/func_800D128C, measured closeness 105 when they merged) <sub>L31486</sub>
|
||||
- **§353** — USE `-fno-thread-jumps` AS AN **ORACLE** TO PROVE A RESIDUAL IS thread_jumps, THEN LAUNDER THE *VALUE* TO KEEP A DEAD RE-TEST (P31 S67; byte-proven ov_SC01_008/func_8017EC68, 279 ins) <sub>L31519</sub>
|
||||
|
||||
|
||||
---
|
||||
@@ -3568,3 +3570,4 @@ Notes routinely quote that as a section id. This table resolves it. Grep bait: `
|
||||
| L31435 | §350 | A ZERO-BYTE RE-TIE SETS `reg_n_sets=2`, WHICH KILLS sched1's `birthing_insn_p` LAUNCH_PRIO |
|
||||
| L31456 | §351 | `/s` (MEM_IN_STRUCT_P) IS A DIAL YOU CHOOSE PER ACCESS: A COMPONENT_REF GRANTS IT AND LETS |
|
||||
| L31486 | §352 | ⚠ TWO IDENTICAL `__asm__ __volatile__("")` BARRIERS **MERGE WITH EACH OTHER** — SPELL THE |
|
||||
| L31519 | §353 | USE `-fno-thread-jumps` AS AN **ORACLE** TO PROVE A RESIDUAL IS thread_jumps, THEN LAUNDER |
|
||||
|
||||
@@ -31515,3 +31515,26 @@ Two ordinary fixes worth the pattern: a clamp must be `if/else` plus a SEPARATE
|
||||
because a `?:` const-folds `0x14*25` to 500; and the definition needed `(s32 arg0, s32 arg1)` with
|
||||
`(u8)`/`(s16)` casts INSIDE, because `resident.c:1693` already declares the prototype at file scope
|
||||
(gcc-2.7.2 rejects `+` asm constraints).
|
||||
|
||||
## §353 — USE `-fno-thread-jumps` AS AN **ORACLE** TO PROVE A RESIDUAL IS thread_jumps, THEN LAUNDER THE *VALUE* TO KEEP A DEAD RE-TEST (P31 S67; byte-proven ov_SC01_008/func_8017EC68, 279 ins)
|
||||
|
||||
A surviving "dead" `bne $s0,$v1` re-test in the target looks impossible to reproduce: `thread_jumps`
|
||||
deletes the label, and cse then folds the comparison away. §308 read in REVERSE gives the lever —
|
||||
**launder the VALUE, not the control flow**:
|
||||
|
||||
__asm__("" : "=r"(w) : "0"(w)); /* in place, on an s32 w */
|
||||
|
||||
With the value laundered, cse can no longer prove the comparison redundant and the re-test survives.
|
||||
|
||||
**THE DIAGNOSTIC IS THE REUSABLE PART:** compile once with **`-fno-thread-jumps`**. If the residual
|
||||
disappears, the pass is identified and you are looking for a value/label-liveness dial, not a
|
||||
scheduling or allocation one — here it took the count 4 → 1 immediately and named the target. Add it
|
||||
to the same toolbox as `oracle_reorder.py` (proves an `as -O1` epilogue wall) and `cc1 -dS`/`-dL`
|
||||
(prove a sched1 priority or a loop.c threshold): **a per-pass disable flag is a cheap oracle for
|
||||
"which pass is doing this".**
|
||||
|
||||
Also from this function, and it is the §347/§162 pattern again: the shared
|
||||
`D_801A3458 = p; beep; return 0;` tail must be a source-level `goto` placed in case 0's LAST arm —
|
||||
leaving it to cross-jumping gives **341 instructions against the target's 279**. Cross-jumping
|
||||
re-merges what you duplicate (§347 lever 1), but it will not INVENT the jump structure a source
|
||||
`goto` expresses.
|
||||
|
||||
Reference in New Issue
Block a user