Compare commits

...

8 Commits

Author SHA1 Message Date
Devin AI
1b1d8478ee fossils: volatile-cast lever assessed on _create_icon — webs are address math, not polled reloads
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 05:59:23 +00:00
Devin AI
fa54f5273b fossils: document w1011e decode batch — inputChar dead-cmp fossil + dTT/#1305 rotation + _create_icon assoc
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:30:58 +00:00
Devin AI
1d98763ae1 fossils: drop dTT source changes in favor of merged #1305
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:41 +00:00
Devin AI
c3e418f687 fossils: dTT insn-equal via if+while guards, addic. fuse, hoisted needles
- newline counter: if+while (beq guard + b-to-test) replaces if+do-while
- totalLines guard if(totalLines>0)+while -> addic.+ble zero-trip fusion
- named sep needles inside guard blocks -> callee-reg hoisted args
- fmuls operand order via visibleRows * rowHeight
- 447v451/38d -> 451v451/36d; residual = frame-slot packing + reg renames

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:33 +00:00
Devin AI
77883a9e61 fossils: structural-decode pass on inputChar compare fossil — wall confirmed
~10 more arm variants (dead-store arms, control forms, narrow/uninit
index decls, count-as-index) all fold or add insns. Wall documented: the
phi arm must emit zero insns while keeping the index symbolic — requires
MWCC to elide both the arm li and the guard branch; likely a phase-order
quirk no source form reproduces.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:27 +00:00
Devin AI
65c25e01f4 fossils: scheduling/opt-level pragma pass — all levers inert or regressions
- dTT: scheduling 604/750/7400, schedule_twice, opt_level 0/2/4, TU
  -ipa function/off, -O4 variants, shared-gx, named-assign objects —
  451/451 insn-equal stands at 90d; residual = slot-pool assignment +
  arg remat + reg permutation (documented pool-overlay decode)
- inputChar: all scheduling/opt/ipa inert; committed -O4,p is
  load-bearing (removing drops 4 insns); bool-assign arm rejected
- _create_icon: all levers inert (20d) or regressions

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:27 +00:00
Devin AI
82dde0ce67 fossils: ppc_iro_level + discarded-temp decode -> insn-equal on 2 fns
drawTransferTitles: #pragma ppc_iro_level 0 + bare discarded
nw4r::ut::Color(*re) statement keeps the third copy alive => 451/451
insn-equal (was 438/451). Residual: frame +0x10, temp-slot packing,
mr-vs-addi remat, reg coloring.

inputChar: ppc_iro_level 4 + inputBuf second-pointer + phi arm =>
136/136 insn-equal (was 125/136). Residual: compare-without-branch
fossil arm (produces no insns in orig), mr-vs-addi base copy.

_create_icon: pragma rejected (0 and 1 both regress 100v100->124v100);
committed form stands.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:27 +00:00
Devin AI
1c7e31510e tiString inputChar: symbolic-index decode (135/136); document fossils walls
inputChar: u32 inputIndex + if(ch==10) phi reproduces orig's symbolic
indexed stores + clrlwi count-narrow (135/136, was 125/136). Dead
cmplwi fossil remains - no source form emits compare-without-branch.

Documented: drawTransferTitles three-Color-copy structure (orig keeps
one dead Color copy per call; every eliminability lever fails), create
3-web pin rotation, _create_icon remat-vs-pin - all allocator-internal.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-09 04:10:27 +00:00
4 changed files with 225 additions and 3 deletions

View File

@@ -163,6 +163,8 @@ private:
};
}
#pragma push
#pragma ppc_iro_level 4
void Decolated::inputChar(wchar_t ch) {
if (ch != 0xfffe) {
wchar_t input[8];
@@ -195,9 +197,16 @@ void Decolated::inputChar(wchar_t ch) {
}
nonKana:
if (mTranslateMode == 3) {
CharacterOutput output(input);
output.append(ch);
count = output.finish();
u32 inputIndex = 0;
wchar_t* inputBuf = input;
input[inputIndex] = 0;
if (ch == 10) {
inputIndex = 0;
}
input[inputIndex] = ch;
++inputIndex;
inputBuf[inputIndex] = 0;
count = inputIndex;
mKanaStream.mOutput[0] = 0;
} else {
count = 1;
@@ -220,6 +229,7 @@ inputReady:
mCursorEnd = mCursorStart;
}
}
#pragma pop
void Decolated::confirmKana() {
inputChar(10);

View File

@@ -0,0 +1,30 @@
## Wave w1011c — scheduling/opt pragmas on _create_icon (no movement)
Baseline 100v100 insn-equal, 20 diff ops (remat-vs-pin wall):
- `scheduling 604` → 26d (worse); `scheduling 750`/`schedule_twice on` → 20d (inert)
- `optimization_level 2` → 104 insns (+4, 11d) — rejected
- `ppc_iro_level 2/3` → 21d/20d (inert); IRO 0/1 previously regressed to 124v100
- TU `-ipa function`/`-ipa off` → 20d (inert); TU `-O4,p` → 20d (inert)
## w1011e — _create_icon decode progress
Orig pattern decoded: literal `&mFileCell[slot][file].icon` in first call arg
(recomputed per call) + NAMED local declared between calls -> "recompute + pin"
(`add r3,sum; bl; add r24,sum; mr r3,r24`). texObj/tlutObj named locals reproduce
the pin structure — diff moved to pure reg rotation but stays 20d.
Assoc fossil: orig groups `+0x10EC` (0xFE8+0x104 = member+icon offsets) into the
ROW base BEFORE `file*0x15c` — `((this+slot*S)+0x10ec)+file*0x15c`. Natural
`[slot][file].member` assoc is index-first. cell*/flat-byte/row-ref variants
regress (26/24/24). Also orig saves args r25-r28 vs mine r24-r27 — one extra
early callee web again.
## w1011f — volatile-cast lever (#1309 idiom) assessed
`((volatile memorycard::IconState*)icon)->member` tried at three granularities:
named vicon local on all member reads -> 98v100 (-2 insns, 25d); site-casts on
fmt+offset+tlutOffset -> 98v100/25d; site-cast on iconOffset only -> 100v100/20d
(neutral, single-use read). Verdict: fossils' webs are ADDRESS arithmetic
(recomputed base+off per call arg), not polled member reloads — the volatile
lever doesn't apply. IconState's own volatile members (bannerEnable etc.)
are already correctly declared in the header.

View File

@@ -0,0 +1,93 @@
## drawTransferTitles (w1011/fossils) — three-Color-copy structure fully decoded
Orig emits THREE nw4r::ut::Color copies per setTitleRowColors call site, not two:
active branch: read GXColor@0x3c once (lbz x4 into r8/r7/r6/r0), byte-memberwise
stb x4 to THREE dests: 0xc (DEAD - never read again), 0x24 (arg1), 0x20 (arg2).
inactive branch: source 0x38 -> dests 0x8 (dead), 0x1c (arg1), 0x18 (arg2).
So orig keeps one dead Color copy per call; MWCC always eliminates ours.
Byte-memberwise copies = implicit Color copy ctor (u8 fields), source read
through reinterpret_cast<const Color*> (opaque alias -> lbz not lwz).
Forms tried to keep the third copy alive - ALL eliminated or word-folded:
- named `Color active0 = *re` (leaf-start form): dead-eliminated -> 2 copies.
- `Color(active0)` temps: active0 stored (copy source) but temps word-fold
(lwz+stw) -> wrong shape AND fewer byte ops.
- `setTitleRowColors(tb, active0, active0)` by-value params: callee ABI adds
caller-side copies but they word-fold (Color is 4B -> memcpy fold).
- `const Color& r = Color(*re)` ref-bound temp: still eliminated.
- `const` decl: no effect.
Unresolved: what makes orig's third copy non-eliminable. Suspects: a ctor
form MWCC treats as non-trivial-init, an address escape we haven't tried, or
the copy being emitted through a different expression class entirely.
## create (w1011) — reconfirmed 1064v1064 pure tie
3-web callee-pin rotation (litbase->r31, singleton-base->r26, obj->r30 vs
r30/r31/r26) - allocator-internal, matches prior documentation.
## iplMemoryCardManager _create_icon (w1011) — remat-vs-pin reconfirmed
100v100, 37 diffs, all association/coloring: m19-24 address reassociation
(`add r0,r31,r3; add r29,r30,r0; add r3,r29,r28` vs orig
`add r0,r3,r29; add r31,r0,r30; add r3,r31,r28`) and callee-web pin rotation
r29/r30/r31 + r24-r28. Rematerialization order of the *0x1fc0 / *6 / *0x15c
products is allocator-internal - no source lever found in prior or this wave.
## drawTransferTitles (w1011b) — ppc_iro_level 0 + discarded temp => 451/451
`#pragma push` + `#pragma ppc_iro_level 0` around drawTransferTitles, with a
bare discarded statement `nw4r::ut::Color(*reinterpret_cast<const Color*>(&gx));`
before each setTitleRowColors call => insn-equal 451/451 (was 438/451).
Mechanism: the discarded prvalue's construction is side-effectful enough to
survive at IRO-0 (dies at default IRO — verified: removing pragma => 438/451).
This IS the mechanism that kept orig's third copy: a discarded temp.
Remaining 90 diffs = packing/coloring: frame 0x150 vs 0x140 (+0x10), my
dead temps at 0x1c/0x10 vs orig 0xc/0x8 (orig's claim the two LOWEST slots —
probably created earliest in the fn, not branch-local), arg addrs via mr from
pinned regs vs orig's fresh `addi r4,r1,0x1c` (orig's temp addrs remat per-use),
and reg-home permutation r17-r28 <-> r22-r31. Fn-top decls fix the frame to
0x140 but turn copies into `bl` ctor calls (assignment not copy-init). Union
overlay: rejected (Color non-trivial; GXColor union assign folds to lwz+stw).
## _create_icon (w1011b) — pragma REJECTED
ppc_iro_level 0 AND 1 both worsen 100v100 -> 124v100 (remat is desirable here —
orig compiled at a level where remat happens). Committed form stands; the
association+pin diff is allocator-internal, not an IRO artifact.
## Wave w1011c — scheduling/opt-level pragmas + slot-pool analysis (no movement)
All pragma levers on drawTransferTitles (451/451 insn-equal baseline, 90 diff ops):
- `scheduling 604` → 96d (worse); `scheduling 750`/`7400`/`schedule_twice on` → 90d (inert)
- `optimization_level 0` → 699 insns (disaster); `level 2` → 447 (kills copies); `level 4` → 90d
- TU `-ipa function`/`-ipa off` → 439 insns (LOSES dead copies — ipa phase also eats the discarded-temp construction)
- TU `-O4,p` → 430 insns (peephole kills copies even at IRO-0); `-O4` → same
- shared fn-scope GXColor → 88d (slightly fewer, same walls)
Named dead objects (`Color deadActive = *re` fn-top, in-branch assign): emits `bl` operator= calls
NOT inlined at IRO-0 → +1 insn (452v451). Copy-assign does not inline; only the discarded-prvalue
construction inlines.
Slot-pool decode: orig's dead temps at 0x8/0xc live in a shared low pool also used by other objects
(o393 `stw r3,0x10`, o395 `addi r4,r1,0x10` — sret/arg objects overlay). Mine allocates its pool
starting at 0x10. The dead temps' lifetimes end before the call in both; orig overlays them onto
the lowest pool slots, mine doesn't — pure allocator slot-assignment, no source lever found.
Other residual diffs (unchanged): `mr rN,rM` arg-copy pins vs orig `addi rN,r1,slot` remat,
whole-fn reg permutation (prologue saves), frame 0x150 v 0x140.
## w1011d — structural decode wave (fn-local-static dispatch → decoded to control-form + temp-pool)
Dispatch hinted fn-local statics (BS2Update #1299). Assessed all 3 fossils: statics emit stw/.bss insns — wrong direction for fn needing insn-equal or zero-insn arms. Instead structural decode on dTT landed insn-equal:
**drawTransferTitles 447v451/38d → 451v451/36d** (upstream's GXColor-copy form + decode):
- Newline-counting loop: orig uses redundant `if (newline != NULL) { while (newline != NULL) {...} }` — `beq` guard + `b`-to-test while-entry. Plain `if+do{}while` emits body-first (no `b`); `while` alone loses the guard.
- Needle arg: TWO separate webs — `li r4,0` for first wcsstr (literal), hoisted callee-reg `mr r4,r21` for loop calls → sep declared INSIDE the if-block, first call uses literal/different-named var.
- lineIndex loop: `totalLines = lineCount + 1` + `if (totalLines > 0) { while (lineIndex < totalLines) {...++lineIndex;} }` → MWCC fuses the +1 into `addic.` + `ble` zero-trip + `b`-to-cond. `for(;i<N;i++)` or `if(i<N)` guard gives `addi`/`cmpw`-`bge` (no fusion).
- `fmuls` operand order fixed by `static_cast<f32>(visibleRows) * rowHeight` (was `rowHeight * ...`).
**Remaining 36d (allocator-internal)**: frame slot assignment — orig packs the 3 per-branch GXColor copies into the LOWEST pool (dead@8/0xc, args@0x18-0x24) interleaved with iterator objects; ours groups them higher (0x20-0x3c). Also r30↔r31 rodata-base swap, callee-web renames. Arms failed on slots: decl-order perms, fn-top decls (regresses to word-copies), nw4r::ut::Color-typed copies (+4 insns), discarded `Color(*re)` temp (+4, wrong pool class).
_create_icon 100v100/20d: callee-web rotation + remat-vs-pin (orig recomputes `base+off` for the call arg AND pins it — CSE prevention needs two syntactically-different exprs, none found).
## w1011e — post-#1305 residual analysis (upstream's form)
dTT now upstream's version: 451v451/38d, fuzzy 99.39. All 38 diffs = wholesale
callee-reg rotation (orig r30=rodata-base, r31=byte-flag lbz 0xcd, r22/23=line counter;
mine r31/rodata, r29/flag, r19/counter) — the "+1 callee web" family again: orig pins
one more callee web (a member byte live across calls). Decl-order swaps tried:
lineIndex/totalLines, titleIndex/nandTitleIndex, footerPane/titleText,
lineCount/messageForCount -> 38/44/38/38. Allocator-internal wall confirmed.

View File

@@ -28,3 +28,92 @@ call result, or a non-foldable form). Dead `cmplwi r4,0xa` matches the documente
dead-compare-fossil family (both-branch merge). Also: count lands in r29 via
clrlwi (u16) — count is i.
Unresolved: what source produces symbolic-index stores + dead compare.
## inputChar (w1011/fossils wave) — symbolic-index DECODED, dead-compare wall remains
Best: 135/136 (was 125/136). The winning source form:
```cpp
u32 inputIndex = 0;
input[inputIndex] = 0;
if (ch == 10) { inputIndex = 0; }
input[inputIndex] = ch;
++inputIndex;
input[inputIndex] = 0;
count = inputIndex; // u16 count: emits clrlwi r29,r6,0x10
mKanaStream.mOutput[0] = 0;
```
The `if(ch==10) inputIndex=0` creates an SSA phi on inputIndex -> MWCC keeps the
index SYMBOLIC -> reproduces orig's `slwi/sthx/addi/slwi/clrlwi/sthx` sequence
and the clrlwi count-narrow between the two sthx (u16 count, not int).
REMAINING GAP = dead `cmplwi r4,0xa`: orig emits the compare with NO consuming
branch and NO arm insns. Every arm-body variant fails both ways:
- arm with any real op (`inputIndex=0`, `mOutput[0]=0`, `count=inputIndex`,
`input[0]=0`): MWCC keeps `bne` + arm insns (mine 135 = +bne+li vs orig).
- empty arm `if(ch==10){}`, self-assign `inputIndex=inputIndex`, dead-on-arrival
`count=inputIndex` (overwritten unconditionally after), identical-arms
if/else, ternary `(ch==10)?0:inputIndex`: MWCC merges arms BEFORE emitting the
compare -> compare dies too (125).
A compare-without-branch fossil is not producible by any tested source form on
MWCC 3.0a5.2. Open question: whether orig's compare came from a non-if codegen
path (peeled loop head, && short-circuit whose second test folds, or an
MWCC-version difference).
## inputChar (w1011b) — ppc_iro_level pragma + insn-equal 136/136
`#pragma push` + `#pragma ppc_iro_level 4` around inputChar + `wchar_t* inputBuf
= input` second-pointer for the last store + `if(ch==10) inputIndex=0` phi-arm
=> insn-equal 136/136 (was 125/136). Orig's symbolic index IS a phi.
Remaining 7 diffs: orig's `if(ch==10)` emits ONLY the cmplwi (no bne, no arm
insns — a true compare fossil), orig's second-store base is `mr r4,r5` copy vs
my addi rematerialization, plus r5<->r6 zero-web color and tail clrlwi position.
Fossil-arm variants that ALL fail (arm must produce phi + zero insns): empty
arm (folds everything), inputIndex=inputIndex (phi collapses), (ch==10)?0:i /
?i:0 ternaries (diamond or full fold), input[0]=0 arm (emits sth),
input[inputIndex]=0 arm (emits sthx), opt_dead_code/opt_dead_assignments/
opt_common_subexpressions pragmas at IRO-0 (all still bne+li), iro 0-4.
Compare-without-branch remains non-producible; likely needs the arm's value to
materialize in the SAME register as the init (a CSE level mine never reaches).
## Wave w1011c — scheduling pragmas on inputChar (no movement)
On the 136/136 insn-equal form (IRO-4 + inputBuf + phi arm, 7 diff ops):
- `scheduling 604` → 18d (worse); `scheduling 750`/`schedule_twice on` → 7d (inert)
- `optimization_level 0` → 151 insns; `level 2` → 139 insns (+3)
- TU `-ipa function`/`-ipa off` → 7d (inert)
- TU `-O4,s` or NO extra_cflags → 132 insns — the committed `extra_cflags=["-O4,p"]` is
LOAD-BEARING: removing it drops 4 insns (kills the symbolic-index sequence)
- bool-assign arm `u32 v=(ch==10); inputIndex=v-v` → cntlzw materialization (135,11d) — rejected
## Wave w1011d — structural decode pass on inputChar compare fossil (~10 more variants)
Decoded orig emission (o64-79): `cmpwi r6,3; bne; li r6,0; sth r6,0x10; cmplwi r4,0xa(dead);
slwi r0,r6,1; addi r5,r1,0x10; sthx r4; addi r6,r6,1; mr r4,r5; li r5,0; slwi; clrlwi r29;
sthx; sth 0x42; b` — index stays symbolic via a phi whose arm emits ZERO insns.
New arms tried (all fold or add insns):
- dead-store arms: `input[0]=0`, `mKanaStream.mOutput[0]=0` → 130v136 (arm folds, kills sequence)
- control forms: `if(ch==10);` empty → 125; `while(ch==10){}` → 129
- `inputIndex=inputIndex+0` → 125; `input[inputIndex]=0`/`inputBuf[0]=0` arms → 130
- `u16/s32 inputIndex` → 137(+1)/136(same); `count` as index → 137 insns, 5 diff ops but
rlwinm-masked index (u16) + bne/li arm remains
- `u32 inputIndex;` UNINIT + arm `=0` → 128v136 (whole block folds to direct stores — MWCC
collapses uninit index to 0-folded direct offsets, losing the symbolic-index sequence)
Wall (final): a phi whose arm-side definition emits zero insns — only realizable if MWCC
elides BOTH the arm's li and the guard branch; no source form does it while keeping the
index web symbolic. Compare fossil likely requires an MWCC phase-ordering quirk
(compare emitted, then its branch consumer folded by a later pass that doesn't re-dce).
## w1011e — MSL-overload/dead-arm batch on the compare fossil
inputChar committed at 136/136/7d (IRO-4 + u32 inputIndex + inputBuf + `if(ch==10) inputIndex=0`).
Orig idx-68 `cmplwi r4,0xa` is a TRUE dead compare — no branch consumer, flows straight into
the symbolic-index stores. Fossil = a folded `if` whose compare outlived its branch.
Variants (all -> 125 full-fold or live-arm real insns):
- dead-arm no-ops: `i += 0`, `i |= 0`, `i *= 1`, `i = i|0`, `i = 1; i = 0`, `count = 0`, `i = i` -> 125
- folded calls: `wmemset(input, 0, 0)` arm -> 125
- expr-form: `input[i] = (ch==10) ? ch : ch`, `if (ch==10) goto L; L:` -> 125
- always-true guard: `if (ch == 10 || inputIndex == 0)` -> 125
- count type: `u32`/`s32`/`int` count (+static_cast<u16> at uses) all collapse index to 125.
`u16 count` is LOAD-BEARING for the symbolic index; orig re-narrows per use
(`clrlwi r0,r29,0x10` at both mCursorStart adds) — its count web is wider-typed
but the u16 decl is what keeps OUR index symbolic. Unsolved contradiction.