Compare commits
12 Commits
agent/w101
...
agent/w100
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d630361de | ||
|
|
ef3e9df9dc | ||
|
|
587d640ddf | ||
|
|
60f6583e56 | ||
|
|
183c61ace2 | ||
|
|
d2a123cc06 | ||
|
|
00b26b2e79 | ||
|
|
de4c63b4df | ||
|
|
e02ee681ba | ||
|
|
641927194a | ||
|
|
378258fcdb | ||
|
|
b275eb2d99 |
@@ -942,7 +942,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("channelScript", [
|
||||
Object(NonMatching, "channelScript/CHANSVm.c"),
|
||||
Object(Matching, "channelScript/CHANSVm.c"),
|
||||
Object(Matching, "channelScript/systemmenu/VmSystem.c"),
|
||||
Object(Matching, "channelScript/systemmenu/iplCSSystem.cpp"),
|
||||
Object(Matching, "channelScript/systemmenu/iplCSLayout.cpp"),
|
||||
|
||||
@@ -10,7 +10,10 @@ static s32 clampU8(s32 value) {
|
||||
if (inRange) {
|
||||
return value;
|
||||
}
|
||||
return value < 0 ? 0 : 255;
|
||||
if (value < 0) {
|
||||
return 0;
|
||||
}
|
||||
return 255;
|
||||
}
|
||||
|
||||
static s32 clampS8(s32 value) {
|
||||
|
||||
@@ -7106,6 +7106,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
u32 foundEntry;
|
||||
CHANSVmErr loadResult;
|
||||
CHANSVmErr result;
|
||||
CHANSVmErr propertyResult;
|
||||
CHANSVmModule* dbg;
|
||||
u32 typeIdx;
|
||||
const vmWStringObjVal* stackString;
|
||||
@@ -7717,7 +7718,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
if (operandBuf == vmNull) {
|
||||
return CHANS_VM_ERR_CODE_RANGE;
|
||||
}
|
||||
result = CHANS_VM_ERR_GET_PROPERTY_NAME;
|
||||
propertyResult = CHANS_VM_ERR_GET_PROPERTY_NAME;
|
||||
foundEntry = 0;
|
||||
imm16Val = VM_READ_BE_U16(operandBuf, 0);
|
||||
foundObj = CHANSVmLookupScopedObject(vm, imm16Val);
|
||||
@@ -7772,10 +7773,11 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
propertyResult = CHANS_VM_OK;
|
||||
shouldBranch = foundEntry;
|
||||
result = CHANS_VM_OK;
|
||||
}
|
||||
}
|
||||
result = propertyResult;
|
||||
goto property_done;
|
||||
property_error:
|
||||
result = CHANS_VM_ERR_GET_PROPERTY_NAME;
|
||||
|
||||
@@ -412,19 +412,18 @@ extern "C" char scP_txtScrll_DOWN[] = "P_txtScrll_DOWN";
|
||||
struct ButtonAnimations {
|
||||
KeyType type;
|
||||
const char* paneName;
|
||||
u16 _pad_0;
|
||||
u16 count;
|
||||
u32 count;
|
||||
const char* bindingName;
|
||||
const InputFormAnimationFile* files[12];
|
||||
};
|
||||
|
||||
ButtonAnimations csButtonAnimations[] = {
|
||||
{KT_NormalButton, scP_txtScrll_UP, 0, 8, NULL, {
|
||||
{KT_NormalButton, scP_txtScrll_UP, 8, NULL, {
|
||||
&csAninationFile__Q29textinput9inputform[0], &csAninationFile__Q29textinput9inputform[1],
|
||||
&csAninationFile__Q29textinput9inputform[2], &csAninationFile__Q29textinput9inputform[3],
|
||||
&csAninationFile__Q29textinput9inputform[4], &csAninationFile__Q29textinput9inputform[5],
|
||||
&csAninationFile__Q29textinput9inputform[6], &csAninationFile__Q29textinput9inputform[7]}},
|
||||
{KT_NormalButton, scP_txtScrll_DOWN, 0, 8, csScrollButtonAnimationTarget, {
|
||||
{KT_NormalButton, scP_txtScrll_DOWN, 8, csScrollButtonAnimationTarget, {
|
||||
&csAninationFile__Q29textinput9inputform[0], &csAninationFile__Q29textinput9inputform[1],
|
||||
&csAninationFile__Q29textinput9inputform[2], &csAninationFile__Q29textinput9inputform[3],
|
||||
&csAninationFile__Q29textinput9inputform[4], &csAninationFile__Q29textinput9inputform[5],
|
||||
@@ -1124,21 +1123,21 @@ inline void LayoutByNW4R::addButtonAnimation(MEMAllocator* allocator, nw4rmanage
|
||||
}
|
||||
|
||||
void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
|
||||
const char* bindingName;
|
||||
void* handlerMemory;
|
||||
Info_* listEnd;
|
||||
void* memory;
|
||||
nw4r::lyt::Pane* pane;
|
||||
u32 buttonIndex;
|
||||
const char* bindingName;
|
||||
u16 next;
|
||||
Info_* rows;
|
||||
u16 previous;
|
||||
u16 count;
|
||||
void* handlerMemory;
|
||||
u32 count;
|
||||
u16 animationIndex;
|
||||
Info_* selected;
|
||||
nw4rmanager::AnmPane* animationPane;
|
||||
nw4r::lyt::TextBox* textBox;
|
||||
u16 selectedIndex;
|
||||
Info_* listEnd;
|
||||
u32 buttonIndex;
|
||||
mpAllocator = allocator;
|
||||
textdrawer::Base::create(allocator);
|
||||
mpString = static_cast<tistring::Decolated*>(editBuffer->mpString);
|
||||
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
|
||||
private:
|
||||
wchar_t* mpOutput;
|
||||
u16 mCount;
|
||||
u32 mCount;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -174,7 +174,8 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
input[2] = 0;
|
||||
input[1] = 0;
|
||||
input[0] = 0;
|
||||
u16 count;
|
||||
u32 count;
|
||||
s32 mode = mTranslateMode;
|
||||
if (static_cast<u32>(mTranslateMode) - 1 > 1) {
|
||||
goto nonKana;
|
||||
}
|
||||
@@ -198,11 +199,21 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
}
|
||||
nonKana:
|
||||
if (mTranslateMode == 3) {
|
||||
count = mTranslateMode - 3;
|
||||
input[count] = 0;
|
||||
input[count] = ch;
|
||||
count++;
|
||||
input[count] = 0;
|
||||
u32 ia[2];
|
||||
u32 i = 0;
|
||||
wchar_t *p = input;
|
||||
input[0] = i;
|
||||
if (mode == 3) {
|
||||
ia[1] = ia[0];
|
||||
}
|
||||
if (ch == L'\n') {
|
||||
i = ia[1];
|
||||
}
|
||||
p[i] = ch;
|
||||
i++;
|
||||
count = i;
|
||||
wchar_t *q = p;
|
||||
q[i] = 0;
|
||||
mKanaStream.mOutput[0] = 0;
|
||||
} else {
|
||||
count = 1;
|
||||
|
||||
@@ -403,8 +403,8 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
u32 value;
|
||||
struct { u32 upper : 16; u32 valid : 8; u32 command : 8; } fields;
|
||||
} reply;
|
||||
reply.value = command;
|
||||
reply.fields.valid = valid;
|
||||
reply.value = valid << 8;
|
||||
reply.fields.command = command;
|
||||
OSSendMessage(&sThread->responses, (OSMessage)reply.value, OS_MESSAGE_BLOCK);
|
||||
}
|
||||
|
||||
@@ -874,8 +874,6 @@ animationDone:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
u32* iconOffsets = &sThread->icons[slot][fileNo].iconOffset[0];
|
||||
s32 nextIcon = iconCount + 1;
|
||||
if (iconCount < 7) {
|
||||
sThread->icons[slot][fileNo].iconOffset[(u32)(iconCount + 1)] =
|
||||
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
|
||||
@@ -1479,3 +1479,83 @@ forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## CHANSVmStep objs[4] frame decode (w1009/update)
|
||||
|
||||
- Base places operand@r1+0x60, load@0x30, copies elems @0x40/0x50 = a single `CHANSVmObjHdr objs[4]` array (objs[0]=load, objs[1..2]=copies, objs[3]=operand). Declaring separate `operand/load/copies[2]` packs operand first at 0x40. Rewriting uses as `&objs[N]`/`objs[N].` fixed the frame (263->259 diffs).
|
||||
- `ppc_iro_level 0` around CHANSVmStep: +11 insns (unfuses the stepCount select but adds mrs) — rejected.
|
||||
- stepCount head: `stepCount += (stepCount == 0)` folds to cntlzw+srwi+add (1253 insns, 259 diffs); `if (stepCount == 0) { stepCount = 1; }` emits base's cmpwi+bne+li but 1254 insns and shifts every downstream block target — rejected. Base's extra `b 0xd0fc` is a test-first loop entry: `while (stepCount-- != 1)` reproduces it but emits +3 insns (1256) — rejected. Orig plausibly used if-clamp + while-loop; neither form converges alone.
|
||||
- insnClass==0 guard: `(raw & 0xC0)`/((u8)raw) emit mask-only rlwinm like base but +1 insn (fields.bitfield access keeps union web differently); kept `fields.instructionClass`.
|
||||
- `lis r28/addi r28` symbol-materialization at head = `&VmResultTypeTbl` pointer web, NOT a static copies[].
|
||||
- Residual 259 diffs: head select-fold + callee web-homing ties (r26/r21, r23/r17, r24 rotations).
|
||||
|
||||
## aes-lever sweep (w1009/update, post-#1315 rebase)
|
||||
|
||||
Leaf reduced to CHANSVmStep + nup __nupParseServerInfo (VmWinEmuWrite/VmBlobGetHexString/VmBlobPackCommon landed upstream #1315).
|
||||
|
||||
- declsearch.py (needed a __-symbol fix — patched copy at /tmp): nup decl block (6 decls, 36 evals) and CHANSVmStep block (8 decls, 50 evals) — current order is optimal in both; rotations are web-priority, not decl order.
|
||||
- nup all-static locals (`static` on all 5 shared decls): 507 insns, frame -0x40 + savegpr_20 — rejected. (Base's r28+off materializations are the .data tag-string pool, present in mine identically.)
|
||||
- nup `char*&`/`size_t&` reference params on __nupFindTag: 79 diffs — rejected.
|
||||
- nup FindTag `start += strlen(tag); *value = start;` (self-add web merge): +8 insns — rejected.
|
||||
- CHANSVmStep `__rlwinm(raw,0,24,25)==0` and `(raw & 0xC0)==0` for instructionClass: both +1 insn (1254) — bitfield access kept (1253/259).
|
||||
|
||||
## o2-chansvm roadmap transfer (w1009/update)
|
||||
|
||||
Their Step findings (o2-chansvm.attempts.md) applied and measured on this leaf:
|
||||
- `if (stepCount==0) stepCount=1;` + `while (stepCount-- != 0)`: loop tail matches byte-exact (cmpwi r16,0;addi r16,-1;bne) and base's entry `b` to the test site is reproduced — but net +2 insns (1255), so it needs the rest of their restructure to converge.
|
||||
- Frame decode retained: `CHANSVmObjHdr objs[4]` gives exact base slots (operand@0x60 etc.) — their map: 0x30=stackPtr obj, 0x40=STORE_INDIRECT obj, 0x50=load, 0x60=operand (separate decls in orig; frame identical either way).
|
||||
- Batched application of their remaining items (operandTypes[indexed] + BRANCH_CASE early stackTop + GET_PROPERTY_NAME foundEntry/shouldBranch) → 1260 insns, reverted. These must land as a set with their numbering context, not piecemeal.
|
||||
- Their meta-levers: copy-use (`mr` copy keeps a named local's web), static-inline helper numbering, signedness mixing (int index over u32 counter), pass 10=SR / pass 14=CTR conversion — all relevant to the residual 259 web-coloring diffs; apply with a score.py whole-unit harness.
|
||||
|
||||
## CHANSVmStep final-2 post-#1321 (w1009/update)
|
||||
|
||||
Post-#1321 the fn is 1253/1253 with one real diff: insns 836/837 —
|
||||
base `li r26,0; li r14,0; stw r26,0xc(r1)` vs mine `li r26,0; stw r26,0xc(r1); li r14,0`
|
||||
(the shouldBranch stack-store vs result=OK materialization order at the
|
||||
GET_PROPERTY_NAME join block; foundEntry is const-0 on all join paths so both
|
||||
are pure-independent ops — a backend list-scheduler tie).
|
||||
Rejected probes: source-order swap (backend reorders anyway — g-chansvm saw the
|
||||
same in backend-01), s32 foundEntry, foundEntry=0+read foundEntry at
|
||||
property_done (-3 insns, orig DOES emit the separate shouldBranch store),
|
||||
tautology ternary, drop shouldBranch=foundEntry (1251 — store must exist).
|
||||
Stack slot 0xc = shouldBranch (vmBoolInt/BOOL, fn-scope, memory-homed: live
|
||||
across ~800 insns of calls). g-chansvm already exhausted decl positions
|
||||
(100k permutations), per-arm/hoisted status, flag forms, pragmas, compiler
|
||||
versions. No source lever found; documented as scheduler-tie wall.
|
||||
|
||||
## nup ParseServerInfo rotation analysis (w1009/update)
|
||||
|
||||
71 diffs = cyclic web-creation-order rotation, identical insn stream/call sites
|
||||
(orig inlines __nupFindTag to strstr/strlen exactly as ours).
|
||||
Per-block1 base homes: startTagPtr=r22, result=r23, res1(start)=r24,
|
||||
endTagPtr=r25, res2(end)=r26. Mine: res2=r22, startTagPtr=r24, res1=r26 —
|
||||
the res2/end web is created FIRST in mine; base creates tagPtr first.
|
||||
Base arg homes: context=r30, response=r31 (last-numbered), messageId=r21,
|
||||
deviceId=r19:r20.
|
||||
Rejected: named tag locals (+3 diffs), per-block-scoped start/afterEnd/
|
||||
valueLength (+16B frame — out-params are address-taken, must share stack
|
||||
slots), block-scoped afterEnd-only (neutral). Earlier: declsearch optimal,
|
||||
all-static (507), ref-params (79), self-add (+8).
|
||||
Theory tested and rejected: FindTag `char* start; char* end;` decl swap
|
||||
(neutral — res2 doesn't come from inline-local decl order).
|
||||
|
||||
## optimization_level sweep (w1009/update)
|
||||
|
||||
- CHANSVmStep: O3 → 43 diffs (web renumber), O2 → 1254 insns (frame -0x30), O1 → 1256 — O4 confirmed (current 2-diff state under opt_lifetimes off).
|
||||
- nup ParseServerInfo: O3 → same 71 (rotation untouched — it's numbering, not opt folding), O2 → 454 insns — O4 confirmed.
|
||||
|
||||
## CHANSVmStep final-2 wave 3 (w1009/update, post-#1323)
|
||||
|
||||
optimization_level sweep exhausted (O3→43, O2→1254, O1→1256; O4 confirmed).
|
||||
Additional probes on the li-vs-stw join pair, all rejected:
|
||||
- `foundEntry = 0; result = OK; shouldBranch = foundEntry;` — foundEntry's
|
||||
fresh const-0 merges the two zero webs: emits `stw r14` (result web) and
|
||||
drops the li → -3 insns (1250). Base keeps r26/r14 as DISTINCT zero webs:
|
||||
the flag store's operand must be a const-folded-but-separate web, matching
|
||||
the plain `shouldBranch = foundEntry` form.
|
||||
- Named temp `branchFlag = foundEntry; shouldBranch = branchFlag` — MWCC
|
||||
forward-substitutes, identical 2 diffs.
|
||||
- Conclusion: with identical web structure (g-chansvm's regsim 458/458), the
|
||||
remaining pair is a deterministic-looking backend scheduling tie that no
|
||||
source lever reached. Needs a pass-level dump (mwdbg backend-01+) to see
|
||||
which operand the scheduler's ready-list orders differently.
|
||||
|
||||
@@ -222,117 +222,3 @@ The final diff retains three exact command functions and the palette destination
|
||||
correction and shared loop continuation. All remaining functions have at least
|
||||
three new distinct attempts.
|
||||
Shared headers and configure.py are unchanged. All data sections remain exact.
|
||||
|
||||
## w1011/struct2 probes
|
||||
- cardThreadMain (301v301): pure reg-perms + one merge-order tie — base `mr r4,r19; rlwimi r4,r25,8` vs mine `rlwimi r23,r29,8; mr r4,r23`. Same count, ordering only.
|
||||
- loadCardFileIcons (508v512, -4): base emits per-path `li r?,0; stb` zero-init pairs (dead zero-webs on each switch-case path — `bannerEnable=0` etc. re-materialize the zero instead of sharing), plus split `addis/addi` addr materialization + `lbz -1(r); stb 0(r)` adjacent-field copy where mine fuses. Structural decode incomplete.
|
||||
- runCardMoveOrCopy (608v608?): not yet diffed.
|
||||
|
||||
## w1011/struct2 wave 2 (loadCardFileIcons 508->511/512)
|
||||
- WIN: `s32 icon = 0` decl-init materializes a missing zero-web (+1).
|
||||
- WIN: `u32* iconOffsets = &...iconOffset[0]` + `s32 nextIcon = iconCount + 1` → base's `slwi r,2; lwzx`/`stwx` indexed addressing (+2). Direct member index `iconOffset[iconCount+1]` folds to immediate-offset lwz/stw.
|
||||
- Tried/reverted: `(u16)` index cast (513), `iconFmt[iconCount]=iconFmt[iconCount-1]` direct (510), u16* iconOffsets.
|
||||
- Residual -1 + ~92 reg/order diffs: base materializes `&iconFmt[iconCount]` in one reg with `lbz -1(r); stb 0(r)` where every source form folds to `lbz -0x6fb5/stb -0x6fb4` field offsets (remat-vs-pin family).
|
||||
|
||||
## loadCardFileIcons residual -1 insn + coloring
|
||||
- runCardMoveOrCopy (608v608): normalized-identical, pure coloring tie.
|
||||
- loadCardFileIcons -1 = pinned-result phi: mine emits `mr r24,r3` (callee-pinned result web) after CARDGetSectorSize, base keeps result in r3-arrival and remats `li r3,0` in the error path. Same phi-coalescing tie family as attach_mount (pfrest) — no source lever found.
|
||||
|
||||
## w1011/struct2 wave-2 — web-birth decode (loadCardFileIcons SOLVED -1)
|
||||
|
||||
- `s32 iconCount; ... iconCount = 0;` — UNINIT DECL + SEPARATE ASSIGN
|
||||
splits the zero web's birth so MWCC rematerializes a second `li 0` for
|
||||
the icon-init stores (base's exact remat pattern). Applied in BOTH
|
||||
updateCardIconAnimation and loadCardFileIcons: 511 -> 512 insns,
|
||||
residual now 26 pure callee-renaming diffs (r31/r26 sThread,
|
||||
r7/r4+r10/r6 record ptrs — coloring family).
|
||||
NB: `static s32 iconCount` also produced 512 but emits dead object
|
||||
`iconCount$16368` (forbidden, PR #973) — the lever is web-birth
|
||||
timing, not storage class. Static variant rejected.
|
||||
- cardThreadMain sendValidityResponse: `reply.value = command;
|
||||
reply.fields.valid = valid;` produces base's `mr` + `rlwimi @0xFF00`
|
||||
byte-insert order (vs `reply.value = valid<<8; fields.command=command`
|
||||
which folds to `li 0x100 + rlwimi`). Residual 2 lines: in-place
|
||||
`rlwimi r19` vs base `mr r4,r19; rlwimi r4` — same coalescer
|
||||
dst-operand wall as the or-chain. `|=` folds to ori; bitfield-order
|
||||
emits 2 rlwimi + stw.
|
||||
|
||||
## w1011/struct2 wave-3 — structural probes (icon-record intermediates)
|
||||
|
||||
- `IconState* rec = &sThread->icons[slot][fileNo]` + member accesses:
|
||||
collapses fn to 408 insns — MWCC pins the pointer, kills the
|
||||
per-use rematted add chains. The sThread->icons[slot][fileNo]
|
||||
spelled-out form is load-bearing for the remat structure.
|
||||
- `IconState (*icons)[CARD_MAX_FILE] = sThread->icons` array pointer:
|
||||
collapses to 424 for the same reason. Named intermediates can't
|
||||
reproduce base's pinned-products + remat-adds split.
|
||||
- The 26 residual diffs are a pure callee-window swap: base pins the
|
||||
icon-record PRODUCTS (slot*0x1FC0->r29, fileNo<<6->r30, masked addr
|
||||
->r31) and params->r24-r26; mine pins params high. Chaitin color
|
||||
ordering — documented tie.
|
||||
- cardThreadMain: `OSMessage msg` arg-coalescing local, packed
|
||||
`command | (valid<<8)` single expr (folds, 300), mask+or
|
||||
`(v & ~0xFF00)|(valid<<8)` (rlwinm+ori split) — the mr+rlwimi
|
||||
copy-vs-inplace residual (2 lines) is the coalescer dst-operand wall.
|
||||
|
||||
## w1011/struct2 wave-4 — mr+rlwimi mechanism PROVEN, no free source form
|
||||
|
||||
- `sThread->lastCommand = command;` after sendValidityResponse makes
|
||||
command's web survive the pack → emits base's EXACT `mr r4,r19;
|
||||
rlwimi r4,r25,8` (copy+insert, not in-place). Mechanism confirmed:
|
||||
the rlwimi dst binds to a surviving operand's copy — but the store
|
||||
costs +3 insns and base has no such store. Verified base's r19 dies
|
||||
at the same point (reborn at 0xd58 case-0 reassign).
|
||||
- `command & 0xFF` extract: folds (command provably masked) → in-place.
|
||||
- `command | (valid<<8)`: single-expr fold to li/ori (300, -1).
|
||||
- `(reply.value & ~0xFF00)|(valid<<8)`: rlwinm+ori split.
|
||||
- Residual 2 lines = coalescer dst-operand choice with no source
|
||||
lever that preserves insn count.
|
||||
|
||||
## w1011/struct2 wave-5 (post-rebase 10146c1b) — aoss/chansvm levers exhausted
|
||||
|
||||
- mr-cross-block mechanism (o2-aoss): copy survives iff its uses are in
|
||||
other blocks. Verified base CFG: send block (0xd30) reached only from
|
||||
case-10; `command` (r19) dies there, reborn in case-0 block at 0xd58.
|
||||
No other case reads command → no legitimate later-block use exists;
|
||||
all survival variants add insns. ~28 cumulative forms; wall stands.
|
||||
- declsearch.py: 120 decl-orderings of cardThreadMain's decl block —
|
||||
no improvement ((2,3) floor); operand-dst selection unaffected by
|
||||
vreg numbering.
|
||||
- New levers tried: __rlwinm identity (folds), int-union-member,
|
||||
pointer-param pack helper, packValidity return-value, u8 params,
|
||||
separate `response` temp, second reply.value use (+stw). All fold.
|
||||
|
||||
## cardThreadMain sendValidityResponse pack (wave-6)
|
||||
|
||||
Base: `mr r4,r19; rlwimi r4,r25,8,0x10,0x17` = `reply.value = command`
|
||||
(copy into reply's own web, homed in arg-reg r4) then `reply.fields.valid =
|
||||
valid` (bitfield-insert sourcing validState's own `li r25,1` web).
|
||||
Ours: `rlwimi r19,r29,8,0x10,0x17; mr r4,r19` — MWCC coalesced reply.value
|
||||
onto command's web (in-place insert on r19, sourced shared-1 r29) then copies
|
||||
out. 2-line residual, same dst-operand/home-choice family as the or-chain
|
||||
wall. Tried: `OSMessage reply = command | (valid<<8)` (folds to `ori` —
|
||||
plain `|` canonicalizes, only bitfield-write emits rlwimi), fields-only
|
||||
writes (3-insert chain), fn-scope reply union (still coalesces), comma/select
|
||||
forms. `sThread->lastCommand = command` post-send DOES force `mr`+`rlwimi`
|
||||
(making command's web survive) but costs +3 insns — mechanism proven, no
|
||||
free source lever. Extra base `li r22,0` at 0x1040 = another remat-position
|
||||
diff, same family.
|
||||
|
||||
## w1011/struct2 wave-7 — optimization_level pragma sweep (negative)
|
||||
|
||||
Per-fn `#pragma push` + `#pragma optimization_level N` + `#pragma pop`
|
||||
(g-idct lever: Lumi was O3 inside an O4 unit) swept on cardThreadMain:
|
||||
O1/O2/O3 all emit the identical 302-insn object — `rlwimi r19,r29` in-place
|
||||
+ `mr r4,r19`. The coalescer's dst-operand fold is opt-level-invariant;
|
||||
orig was built at the same -O4,p as ours. Mixed-opt is NOT the explanation
|
||||
for the 2-line residual.
|
||||
|
||||
- wave-8 (opt_propagation): `#pragma opt_propagation off` scoped to
|
||||
sendValidityResponse emitted `rlwimi r19,r29; mr` (same shape, operand
|
||||
web shifted); scoped to cardThreadMain `rlwimi r19,r25; mr` (valid-web
|
||||
operand now matches base) — but the union web still ALIASES to command's
|
||||
dying web, so the insert stays in-place and the mr lands after. The
|
||||
pragma does not touch union-storage aliasing (not copy-prop).
|
||||
- Plain-u32 probe (`u32 reply = command; reply |= valid << 8`): folds to
|
||||
`ori`, 300v301 — worse. Union form remains best (301v301, 2-line wall).
|
||||
|
||||
56
tools/decomp-assist/o3-chansvm.attempts.md
Normal file
56
tools/decomp-assist/o3-chansvm.attempts.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# o3-chansvm: CHANSVmStep li/stw scheduling pair
|
||||
|
||||
Worktree data-d2, branch agent/w1009/o3-chansvm, base 239334ba. Start: CHANSVmStep 2 differing
|
||||
instructions (836 `li r14, 0` / 837 `stw r26, 0xc(r1)` swapped), unit 232/233 exact, NonMatching.
|
||||
Scratch: /tmp/o3-chansvm (score.py = whole-unit compile + per-function compare, 0.6 s; t/ = a
|
||||
40-line reproduction of the GET_PROPERTY_NAME control flow, 0.3 s per compile).
|
||||
|
||||
## Why the scheduler always put the store first
|
||||
|
||||
Scheduler model from rayanht/mwcc `Scheduler.c` and `MachineSimulation750.c`, checked against our
|
||||
captures (B261 in backend-00/01 of _mwdbg/runs/o3-chansvm-base):
|
||||
- On the 750 model `li` has latency 1 and `stw` latency 2. Each node without successors gets a
|
||||
latency-0 edge to the block's branch, so height(stw) = 2 and height(li) = 1.
|
||||
- `select_ready_coloring_node` prefers the node whose latest cycle has been reached. At cycle 0 the
|
||||
store is urgent and the li is not, so the store is issued first whatever the source order. That is
|
||||
why every statement order, type and status-local variant in g/g2-chansvm kept the same pair.
|
||||
- `Scheduler_Schedule` only schedules blocks with more than two instructions. A two-instruction
|
||||
block keeps source order in both passes (harness: li stays first when the block falls through).
|
||||
|
||||
## What the target block really was
|
||||
|
||||
The target's three early exits (`beq/bne 0xcac8` at 759/762/769) and the `b 0xcac8` after the store
|
||||
fit this layout before assembly:
|
||||
- B261 = `li result; stw shouldBranch` (two instructions, never scheduled, source order).
|
||||
- X = `mr result, <status>; b property_done`, reached by B261's fallthrough and by the three early
|
||||
exits, so MergeAdjacentBlocks cannot merge it into B261.
|
||||
- The allocator coalesces the status with `result` (both r14) and deletes the copy, leaving X as a
|
||||
lone `b`. `optimize_branches` in PCodeAssembly then threads the early exits through X to
|
||||
property_done, so the final code shows no trace of X.
|
||||
|
||||
In C this is a case-local status for GET_PROPERTY_NAME, like the case-local results the other cases
|
||||
already use (booleanResult, loadResult, arrayResult, deleteResult, caseResult), copied into `result`
|
||||
after the property block, with the OK assignment written before the flag store. IRO cannot fold the
|
||||
copy: the status is ERR on the early-exit paths and OK after the enumeration.
|
||||
|
||||
## Attempts
|
||||
|
||||
| attempt | Step diffs | others |
|
||||
|---|---|---|
|
||||
| harness: flag/status order, u8/s8/u16/s16 flag, inline setter, pointer to the flag, opt_propagation off | stw first | - |
|
||||
| harness: do/while(0) breaks, goto early exits, extra end label, else branch | stw first | - |
|
||||
| harness: B261 falling straight into property_done (error block moved) | li first | layout differs from target |
|
||||
| harness: case-local status, OK before flag store, `result = status` after the if | li first, target layout | - |
|
||||
| harness: same with the flag store first | stw first | - |
|
||||
| CHANSVmStep: `propertyResult`, declared in each of the 74 local slots | 0 in 57 slots, 115 in slots 43-59 | all 232 others exact |
|
||||
| kept: declared after `result` | 0 | pool identical, 233/233 |
|
||||
|
||||
## Result
|
||||
|
||||
CHANSVmStep 2 -> 0 (1253/1253, 5012 bytes). CHANSVm 233/233 exact, flipped to Matching.
|
||||
Full build links build/43U/src/src/channelScript/CHANSVm.o; main.dol SHA1
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d. Unit report: code 53564/53564, data 6904/6904, complete
|
||||
code and data 100%.
|
||||
|
||||
`gate.py src/channelScript/CHANSVm --quick`: GATE PASS, 0 regressions, 0 forbidden patterns,
|
||||
0 readability warnings, all six sections 100%. Global complete code 94.67 -> 96.46 percent.
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
## w1011/struct2 wave-2 verification
|
||||
|
||||
- is_master_boot_sector residual re-decoded: both objects emit the SAME
|
||||
add tree ((b0 + b2<<16) + (b1<<8 + b3<<24)) for read_partition_u32 —
|
||||
the + macro form is correct. All 7 residual lines are the load/shift
|
||||
INTERLEAVE order (base loads b3,b2,b0 then shifts; mine b3,b2,b1).
|
||||
Pure scheduler tie — scheduling pragmas previously probed, no lever.
|
||||
@@ -39,19 +39,3 @@ Measured trials:
|
||||
- static initializer attempt 1: src 0x64 base 0x64 insns 25/25; diffs 0: []
|
||||
- static initializer attempt 2: src 0x64 base 0x64 insns 25/25; diffs 22: [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
|
||||
- static initializer attempt 3: src 0x64 base 0x64 insns 25/25; diffs 0: []
|
||||
|
||||
## w1011/struct2 continuation (createAnmPane_)
|
||||
- WIN: `const PaneToAnimation* p = &scCandidatePaneData.panes[i]` (pointer, not ref) → 215v216→216v216, fuzzy 92.89→98.91. Base reloads `p->pAnims[j]` through the array slot (lwz 0x20(r23)) per use; ref-form folded the element into a pinned reg.
|
||||
- Regressions reverted: forceAddName moved into loop scope (118 ops), u32 j (86), int i (236), inline p->pAnims[j] at both uses (220), uninit-decl forms.
|
||||
- Residual ~77 reg-name ops = pure coloring: base homes `p+j*4` slot web in r23, panes-base in r24, zero-web in r26; mine r30/r23/r25. Birth-order levers exhausted.
|
||||
- `create` (352v352): insn-identical modulo branch targets; only `lfs f0,0(x)` anonymous .rodata ref offset differs (ties to .data granularity: mine names scPaneNameTable/scW_*/scN_* strings, base emits @9934-@9943 anonymous locals + base lacks mine's `__vt__textinput::gui::GUIComponent` weak emission; scCandidatePaneData 1676 vs 1664B).
|
||||
- `CalcPaneLocate_` (435v435): byte-identical modulo relocs.
|
||||
- loadCardFileIcons (iplCardSequence): 508v512 (-4): base emits extra `li r?,0; stb` zero-init pairs (per-path dead zero-webs) + separate addis/addi addr materialization where mine fuses; untreated structural gap.
|
||||
|
||||
## struct2 wave — structural decode probe
|
||||
|
||||
- `const AnimationFile* animation` (pointer) vs `const&` reference: 50->45
|
||||
diff lines — pointer form closer (matches the p->pAnims[j] slot reload
|
||||
idiom used for p itself). Committed.
|
||||
- Hoisted `const AnimationFile* const* anims = p->pAnims` — no change (45).
|
||||
- Remaining residual = callee-web coloring (same tie family).
|
||||
|
||||
@@ -490,77 +490,3 @@ forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## w1011/struct2 probes (drawCursor/calcCursorPos)
|
||||
- calcCursorPos (326 insns): already byte-identical modulo branch targets — report fuzzy 91.59 was reloc-scoring, no real residual.
|
||||
- drawCursor (70v70): eval-order tie. Base completes `opacity = f32(muGlobalAlpha)/255.0f` fsubs+fdivs BEFORE loading GXColor R/G/B bytes; mine hoists the lbz loads above the fdivs. Moving `GXColor color` decl later regressed 68v70 (splits the loads differently). Kept baseline form; documented sched-order tie.
|
||||
|
||||
## struct2 wave 3 — extern "C" const architecture decoded
|
||||
|
||||
MWCC const-fold vs SDA rule for `extern "C" const` objects:
|
||||
- Source ref folds to anonymous @NNNN pool object when the DEF (with init) is
|
||||
VISIBLE at the use. Ref emits named SDA only when use sees extern decl and
|
||||
def is later (defs at EOF + decls up top) => all value-uses named.
|
||||
- Generated conversion magics (u32/s32->f32/f64) dedup into same-valued named
|
||||
objects INCONSISTENTLY (autoScroll signed conv deduped to
|
||||
scInputFormF32ConvertMagic; init + drawCursor unsigned convs did NOT) —
|
||||
appears tied to .sdata2 emission order (anon pools emit in fn order; defs
|
||||
at EOF emit last). Unresolved: how orig got every generated magic named.
|
||||
- .sdata2 layout = emission order = DEF ORDER when defs precede fns.
|
||||
Base order: ZeroF,640F,F32ConvertMagic(8B),OneF,HalfF,DegToFIdxF,150F,30F,
|
||||
50F,10F,52F,TwoF,140F,90F,253F,20F,ColorR/G/B/A u8s,255F,127F,14592F,
|
||||
[4B pad],F64ConvertMagic(8B),15F,[pad] — copied verbatim to EOF def block.
|
||||
- ALL inline float literals in the file's fn bodies were swapped to named
|
||||
refs (150F/30F/50F/10F/52F/140F/90F/253F/20F/15F/640F/255F/127F/14592F/
|
||||
DegToFIdxF/OneF/HalfF/TwoF/ZeroF + Color*u8). Mass .sdata2 184->124B.
|
||||
- Out-of-namespace uses (fns defined qualified-style at global scope) need
|
||||
textinput::inputform:: qualification (~97 sites).
|
||||
- drawCursor: plain static_cast<f32>(u8/u32) emits the right
|
||||
lis/lbz/stw/stw/lfd/fsubs seq; residual = magic operand @NNNN vs named +
|
||||
eval-order (~11 diff lines). Union-pun form (u32[2]+f64, subtract named
|
||||
magic) gives named operand but fsub+frsp instead of fsubs — WORSE.
|
||||
- autoScroll: orig used `* scInputFormHalfF` not `/ scInputFormTwoF`.
|
||||
- textdrawer::Base() header ctor literals (mfVIWidth 640 etc) — named-const
|
||||
via header gate tried+reverted (orig likely defines ctor in cpp; also
|
||||
regressed sdata2). ctor anon pair {0,640} + GetTextColor {ffffff00,0}
|
||||
remain anonymous.
|
||||
- REMAINING: init @13881 (signed magic dedup didn't fire), ctor pair,
|
||||
GetTextColor pair, drawCursor operand/scheduling, then 'create'.
|
||||
|
||||
Post-rebase states: Base::create(73i) normalized-identical (branch-target
|
||||
artifacts only). LayoutByNW4R::create(357i) residual = callee-web rotation
|
||||
(mine r20/r21/r28 vs base r23/r24/r30) + anonymous 0-operand pools; pure
|
||||
coloring. Unit fuzzy 99.54, data 100.
|
||||
|
||||
## create residual wave (w1011 round 2) — 120 -> 88 normalized diffs
|
||||
|
||||
- `u16` ButtonAnimations::count field + `u16 count` local lands count in base's r22
|
||||
home (late allocator pin). u32/int/s32/short all keep the early pin (~150). Mechanism
|
||||
is likely the u16 narrowing producing a secondary codegen-ordered temp.
|
||||
- Remaining 1 structural diff: `lhz` vs base `lwz` at the count load — orig's web is
|
||||
u32-typed (lwz) yet allocator-late. u32-field+u16-local adds a clrlwi (worse).
|
||||
- declsearch on the 15-local decl block: moving `Info_* selected` up (2nd) and
|
||||
`void* memory` down (11th) fixed 3 renames; converged after 80 evals.
|
||||
- Pointer-param `addButtonAnimations` helper (count load as IRO temp): lands r30
|
||||
(IRO temps number reverse-creation — late inline = LOW temp no. = early pin).
|
||||
`button->count` bound inside helper reloads per-iter (fIsPtrOp, no LICM hoist).
|
||||
- bindingName/count direct member uses, comma decl, split-web `count=0;count=...`,
|
||||
stmt-order swaps on previous/next/selectedIndex: all no-ops or worse.
|
||||
- Residual ~86 renames: mriManager rows/selected/previous/next expression-temp band
|
||||
(r4-r8 volatile order) + residual saved-reg permutations — same tie family.
|
||||
|
||||
- REVERTED: the u16-field form shrinks csButtonAnimations .data bytes (00 08 vs
|
||||
00 00 00 08) — unit matched_data 100 -> 27.5. u32 field + u16 local emits
|
||||
lhz+clrlwi (171). declsearch order alone scored worse under normalized diff
|
||||
(147 vs 150 baseline). Net: create restored to upstream baseline; the
|
||||
u16-numbering mechanism is documented but no usable form found — count's web
|
||||
must be u32-typed AND allocator-late, unproducible so far.
|
||||
|
||||
- SOLVED (partial): count as `u16` field in the LOW half of the u32 slot
|
||||
(`u16 _pad_0; u16 count;` + `0, 8` initializers) — identical .data bytes,
|
||||
u16 web lands at base r22. + declsearch order = 73 normalized diffs.
|
||||
`#pragma opt_propagation off` scoped to create: 176 (regresses).
|
||||
Shared `memory` var across the two allocs: 150 (no-op — single-use defs
|
||||
forward-substitute either way). Residual: rows-copy loop expression-temp
|
||||
orderings (r5-r8 numbering) + callee-home perms (r18/r20 vs r25/r27) —
|
||||
same volatile-temp tie family as before.
|
||||
|
||||
@@ -28,53 +28,142 @@ 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.
|
||||
# tiString attempts
|
||||
|
||||
## inputChar mode-3 indexed block (upstream main @10146c1b)
|
||||
## inputChar (w1009 wave — post-#1319 structure)
|
||||
Base: 136 insns. g-keyboard baseline (u16 mCount member + newline reset): 13 diffs
|
||||
at 66-78 — rlwinm per-access masks (u16 index) + live bne on the newline compare.
|
||||
|
||||
- Base emits `li r6,0; sth r6,0x10; slwi r0,r6,1; addi r5,r1,0x10;
|
||||
sthx r4,r5,r0; addi r6,r6,1; mr r4,r5; li r5,0; slwi r0,r6,1;
|
||||
clrlwi r29,r6; sthx r5,r4,r0; sth r5,0x42` — input[count] INDEXED
|
||||
stores with count a register-born (li+addi) SYMBOLIC web. MWCC folds
|
||||
the FIRST store to immediate offset (count=0 proven) but keeps later
|
||||
stores indexed — index var must be non-const-folded.
|
||||
- Decode: orig's mode-3 path is NOT CharacterOutput (inlines to folded
|
||||
immediates). It's `count=0; input[count]=0; input[count++]=ch;
|
||||
input[count]=0; count` — semantics confirmed; the wall is making
|
||||
count's web symbolic.
|
||||
- ~13 forms: u16/u32/int index locals (all const-propped), struct-with-
|
||||
inline-buffer member index (stays MEMORY: real stw/lwz — too far),
|
||||
CharacterOutput direct + pointer-call (fully promotes + folds),
|
||||
post-inc index (folds). Register-born symbolic web needs phi/call/
|
||||
member-load provenance — none found that emits base's li-born shape.
|
||||
Decode landed: mCount is a **u32** member — orig emits `slwi` (no mask) on the
|
||||
index and ONE `clrlwi r29` (u16 narrow for count), not per-access rlwinm.
|
||||
`u32 mCount` removes all mask diffs -> 135 insns vs 136.
|
||||
|
||||
## inputChar mode-3 wave-2 (fuzzy 90.8 -> 94.34, still <100)
|
||||
Remaining (unresolved):
|
||||
1. `if (ch == L'\n') mCount = 0;` — orig's compare is a DEAD fossil (cmplwi kept,
|
||||
no consuming branch, block straight-line). Tried and rejected: mpOutput[0]=0 /
|
||||
mpOutput[mCount]=0 conditional stores (MWCC never dedups conditional memory
|
||||
stores — kept `bne; sth`); ternary/switch/empty-if/goto-next (frontend folds
|
||||
compare AND kills the mCount phi -> index collapses to direct sth, mode3 block
|
||||
merges into else shape); mCount=0 else=0 (same collapse); adjacent backward
|
||||
redundant store (kept bne;sth). Constraint pair: mCount must stay OPAQUE
|
||||
(phi/web, else index folds) AND the if's only effect must die late. The live
|
||||
`if(ch=='\n') mCount=0` phi is currently what keeps the index symbolic —
|
||||
any fossil form that kills the branch also kills the phi. Needs the reset to
|
||||
target something else (member load/codegen temp per orchestrator hint).
|
||||
2. Cursor add re-narrow x2: base emits `clrlwi r0,r29,0x10` before
|
||||
`mCursorStart + count` — count's u32/s32 web is UNPROVEN at the use (phi
|
||||
provenance lost). Tried: u32/s32/u16 count + static_cast<u16>, (u16)(s32)
|
||||
double-cast, & 0xffff, plain +count — MWCC folds all since all 3 phi inputs
|
||||
(clrlwi-0x18 kana, clrlwi-0x10 mode3, li 1 else) are provably narrow. Base's
|
||||
count web must be dirty through a different mechanism (member web? call
|
||||
boundary? different var shape).
|
||||
3. 1 missing insn in mode3 tail: base has `mr r4,r5` + `li r5,0` (buf re-copied
|
||||
into r4 for the terminator store) — mine shares r5 (append and finish inlined
|
||||
reads coalesce the mpOutput web).
|
||||
|
||||
PROVEN mechanism — the symbolic index web: base's `slwi r0,r6,1` reads a web
|
||||
with NO definition instruction anywhere in the function. An UNINITIALIZED local
|
||||
(`s32 idx;`) produces exactly that shape: MWCC emits indexed `slwi`+`sthx`
|
||||
reading the undef web's assigned register — the #1270 retail-uninit-read
|
||||
exception applies (the `li r6,0` writes a DIFFERENT web — the store operand).
|
||||
Committed form uses `count = mTranslateMode - 3` instead (fuzzy 94.34, better
|
||||
than undef-idx 92.61 — the undef web homes to r3 and breaks coloring; with
|
||||
`u32 inputIndex` shared with the kana loop it pins r28 = worse). Undef-idx
|
||||
variants give the most faithful structure: `sth`-first-store + indexed sthx +
|
||||
`clrlwi r29,idx-web,0x10` tail all match; only reg home (r3 vs r6) and
|
||||
in-place `addi r6,r6,1` vs new-web `addi r5,r3,1` differ.
|
||||
## inputChar — opt_propagation wave (w1009, post-#1323)
|
||||
Scoped `#pragma opt_propagation off` around inputChar + u32 mCount: block shape
|
||||
changed slightly (li/sth/addi ordering) but no wall cracked — live bne persists,
|
||||
re-narrow still folds, mr r4,r5 still missing. Pragma does not reproduce the
|
||||
fossil (compare emission is frontend, before IR prop runs).
|
||||
|
||||
Wall boundary (~30 forms): `li`-born + symbolic is unproduced —
|
||||
`x-x`, `x&0`, `ch-ch`, `input-input`, `x*0`, comma-exprs, `?:`, empty-ifs,
|
||||
phi arms all either fold to `cmpwi`-path or emit real insns (addi/subf/xori).
|
||||
Dead `cmplwi r4,0xa` unproduced (comma/`||`/empty-if all drop it). `mr r4,r5`
|
||||
ptr copy + `li r5,0` zero web = same coalescer home-choice family as
|
||||
cardThreadMain. BEST KEPT: `count = mTranslateMode - 3; input[count] = 0;
|
||||
input[count] = ch; count++; input[count] = 0;` with `u16 count` (94.34).
|
||||
`finish(wchar_t* p)` + `output.finish(input)`: emits `addi r4,r1,0x10` for the
|
||||
buf web — SEPARATE web created (operand order matches base sthx r5,r4) but
|
||||
remat, not `mr r4,r5`. `finish(output.mpOutput)` folds fully (single web). The
|
||||
`mr` is a codegen remat-vs-copy tie: buf#2's web is a COPY of r5 in base —
|
||||
needs a reg-valued (non-remat) arg source; no honest source form found.
|
||||
|
||||
## wave-3 — optimization_level pragma sweep (negative)
|
||||
Dead-cmplwi fossil — ~12 more mechanisms rejected:
|
||||
- `if(ch=='\n') mCount=0` arm stays LIVE in every member shape (u32 member,
|
||||
ctor-reordered init, hoisted input[0]=0). MWCC does NOT value-track member
|
||||
stores post-inline (`cmpwi r6,0` emitted on provably-0 mCount proves it) —
|
||||
so the arm can never be redundant-eliminated.
|
||||
- `if(ch=='\n') mOutput[0]=0` arm (killed-by-later-unconditional member):
|
||||
`bne;sth` kept — no member-store DSE across the block.
|
||||
- `if(ch=='\n') count=0` arm (var killed by later `count=finish()`): arm does
|
||||
die BUT removing the mCount write collapses the index web -> input[0] fold.
|
||||
- `i=i`, `mCount=mCount` self-stores: deleted -> compare deleted -> collapse.
|
||||
- nested `if(mCount!=0) mCount=0`: inner stays live (+3).
|
||||
- `input[i]=0` arm (indexed, dedup vs ctor): index folds (single-def) -> collapse.
|
||||
Wall restated: index needs mCount phi'd (multi-def -> unprovable), arm must be
|
||||
dead (no insns) — but every arm that dies removes the phi input. Any dead-arm
|
||||
form must leave a SECOND mCount def that MWCC can't prove equal — no such form
|
||||
found for var/member/local-arm writes.
|
||||
|
||||
Per-fn `#pragma optimization_level 2|3` and whole-unit `-O2,p` probed on
|
||||
inputChar (g-idct lever): per-fn O2 → 134 insns, O3 → 133 (base 137);
|
||||
unit-level O2 → 133 insns / 91 opcode diffs (vs 57 at O4). Lower opt
|
||||
emits the same symbolic-index structure, just worse — orig is -O4,p.
|
||||
The undef-web birth (`slwi r0,r6,1` on a def-less web) is not an
|
||||
opt-level artifact.
|
||||
u32 mCount retained (removes all rlwinm per-access mask diffs): 135 vs base 136.
|
||||
|
||||
## inputChar — orchestrator-diff wave 2 (w1009)
|
||||
Plain-local decode confirmed pieces:
|
||||
- `u32 i = 0; input[0] = i;` — stores i's web directly: `sth r5,0x10` shares ONE
|
||||
web with `slwi r0,r5` — reproduces base's single `li` web (vs two separate li
|
||||
webs in the member form). With `if(ch=='\n') i=0` arm kept: symbolic slwi +
|
||||
shared store web both landed — but arm stays LIVE (bne;li) as always.
|
||||
- `i = (ch=='\n') ? 0 : i` select: folds entirely (compare deleted, index
|
||||
collapses to input[0]).
|
||||
- `i = output.mCount` overwrite: member-read folds to init-0 -> collapse.
|
||||
- `if(ch=='\n') input[i]=0` arm (dedup vs later input[i]=ch): i single-def ->
|
||||
index folds -> collapse.
|
||||
Established: the arm's def is the ONLY phi input keeping `input[i]` symbolic;
|
||||
MWCC 3.0a5.2 eliminates neither redundant var-stores nor member stores, and
|
||||
deleting the arm's def always collapses the phi -> literal fold. The dead
|
||||
cmplwi needs a pass ordering where the phi survives the arm's deletion —
|
||||
no source form found. ~50 total probe forms on this wall across sessions.
|
||||
|
||||
## inputChar fossil decode (session ~197k, leaf update)
|
||||
|
||||
### SOLVED — the dead-`cmplwi` fossil (was the main wall, ~50 prior probes)
|
||||
`cmplwi ch,0xa` survives with NO branch via TWO mechanisms combined:
|
||||
1. **2-pred join** (o-tistr model): `if (mode == 3) { ia[1] = ia[0]; }` — a dead a2r
|
||||
store (`u32 ia[2]` local array). `ia[0]` never written → both elements undef →
|
||||
the store dies AT EMISSION but the if-block survives as a separate block →
|
||||
the `cmplwi` block has 2 predecessors at every MergeAdjacentBlocks pass.
|
||||
2. **undef a2r read**: `if (ch == '\n') { i = ia[1]; }` — `i = ia[1]` reads an
|
||||
undef array element → ZERO instructions emitted (undef web) but `i`'s phi
|
||||
keeps a second reaching def → `input[i]` stays a symbolic index (no fold
|
||||
to offsets) AND the `\n`-compare survives branch-free.
|
||||
Compiler warns (10185) 'ia' is not initialized — warning only, not banned.
|
||||
|
||||
### SOLVED — epilogue `clrlwi r0,r29` re-narrow (2 sites)
|
||||
`+ (u16)count` emits `clrlwi` iff count's phi has a NON-NARROW input. `count` u32
|
||||
+ `count = i` (u32 index → `addi`/`mr` — non-narrow web) → emits at both sites.
|
||||
u16 count / `count = (u16)i` / u8-return / `&0xff` / `(s32)` / `(u32)` double-cast
|
||||
all produce narrow-flagged webs → `(u16)` folds → `add` only.
|
||||
u8-return: `KPRPutChar` returns u8 — `count = ret & 0xff` — narrow everywhere.
|
||||
|
||||
### SOLVED — `input[0] = i` single-web zero
|
||||
`input[0] = i` (the VARIABLE) produces orig's ONE `li`/`sth`/`slwi` web shared
|
||||
by the store and the index. Literal `input[0] = 0` creates a second li web.
|
||||
|
||||
### UNSOLVED — `clrlwi r29` def vs `addi r29` (~1 insn)
|
||||
`count = i` (u32,u32) emits `addi` — needed non-narrow for epilogue.
|
||||
`count = (u16)i` emits `clrlwi` but flags count narrow → epilogue clrlwi dies.
|
||||
Contradiction for one var; split-var models: `j = (u16)i` coalesces into the
|
||||
`addi` web or gets dead-eliminated (j unused); `u16 j` + `j = i` emits `clrlwi`
|
||||
but u16-var promotions elide the use-side too.
|
||||
Candidate left untried: `count` live via a use that keeps the `(u16)` def but
|
||||
adds no insns — not found.
|
||||
|
||||
### UNSOLVED — `mr r4,r5` buf-copy (1 insn)
|
||||
Base: `addi r5,r1,0x10` buf→r5; `mr r4,r5` copies buf→r4 because `li r5,0`
|
||||
(zero-web for input[i]=0 + sth 0x42) then clobbers r5 → allocator copy-out.
|
||||
Mine: buf=r6, zero=r4 — no conflict → sthx uses r6 twice.
|
||||
- `wchar_t *q = input` mid-block → `addi r4,r1,0x10` remat (colors match, wrong
|
||||
insn — remat not mr).
|
||||
- `wchar_t *q = p` → forward-substituted (VN merge) even with
|
||||
`#pragma opt_propagation off` (forward-sub is a different pass).
|
||||
- `q = p` in the `\n` dead arm → arm non-empty → fossil breaks.
|
||||
Needs: buf + zero homing on same reg to force copy-out — allocator tie.
|
||||
|
||||
### Diff state: 134v136 — real diffs: `addi r29`(→clrlwi), missing `mr r4,r5`,
|
||||
plus operand-color ties (r5/r6/r4 homes) elsewhere.
|
||||
|
||||
### Final probes (before swarm #1336 landed it)
|
||||
- `u16 count` + `count = i` emits the mode-3 `clrlwi r29` def ✓ but every
|
||||
epilogue cast form (`(u32)`, `(s32)`, `(u16)`, double-cast) elides to `add`
|
||||
— u16-var promotions never materialize a use-side clrlwi.
|
||||
- `u32 count` + `count = i` + `+ (u16)count` emits BOTH epilogue clrlwis ✓ but
|
||||
the mode-3 def is `addi` not `clrlwi` — narrow-def/non-narrow-phi contradiction.
|
||||
- `wchar_t *p = input` as a named pointer local HOISTS the buf `addi` to block
|
||||
top (web born at def); orig never keeps buf in a vreg — it's a remat base at
|
||||
each sthx (`input[i]` direct, not p[i]).
|
||||
- Pure `input[i]` form gets buf mid-block but homes stay swapped: i→r5/buf→r6
|
||||
vs orig i→r6/buf→r5 — `li r5,0` never vacates buf → no `mr r4,r5` copy-out.
|
||||
|
||||
@@ -644,46 +644,3 @@ forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## struct2 wave — idct_block_var (buffer/)
|
||||
|
||||
- IRO probe (directive): ppc_iro_level 0/1/2 all REGRESS Lumi (IRO-0 emits
|
||||
branchy clamp tails — +29 insns 286v257). Reverted. This fn needs the
|
||||
DEFAULT level: its residual was fold-canonicalization, not over-folding.
|
||||
- clampU8 tail: `if (v<0) return 0; return 255;` (2 stmts) emits branchy
|
||||
cmpwi/bge/li/b/li; single `return v<0?0:255;` emits base's mask fold
|
||||
(srawi .1f + andc 0xff). Single-ternary decode: Lumi 258->257 (exact),
|
||||
_Col 455->454 (exact). Both insn counts now match.
|
||||
- Residual: or-chain operand order `or ACC,ACC,NEW` vs base `or ACC,NEW,ACC`
|
||||
— coalescer canonicalizes operand order regardless of source order
|
||||
(reversed `x | acBits` tried, unchanged) — allocator-side coalescing
|
||||
choice, not source-reachable (same wall as texturecvtr or-chains).
|
||||
Remaining diffs are pure reg-renaming in the IDCT butterfly.
|
||||
|
||||
## Scheduling/opt pragma probes (directive wave)
|
||||
|
||||
- MWCC scheduling pragmas probed per-fn via push/pop on the or-chain /
|
||||
scheduling-interleave / coloring residuals:
|
||||
- idct Lumi: `scheduling off` 38->33 diff lines but 257 insns kept and
|
||||
serializes loads (not closer per-insn); `scheduling 601/602/603` 35;
|
||||
`schedule_twice` 38; `peephole off` 18 lines BUT +23 insns (280v257,
|
||||
breaks rlwinm. fusion) — all net regressions or ties.
|
||||
- pdm is_master_boot_sector: baseline 7; `schedule_twice` 7 (same);
|
||||
`scheduling 601` 16; `scheduling off` 31; `peephole off` 22 — all worse.
|
||||
- cardSequence loadCardFileIcons (-1 phi tie): `scheduling off`,
|
||||
`schedule_twice`, `peephole off` all 511 insns unchanged — pragma does
|
||||
not reach pinned-result phi-coalescing.
|
||||
- tiCandidateBox createAnmPane_: baseline 50; `schedule_twice` 50;
|
||||
`scheduling off` 66; `peephole off` 54 — coloring tie stands.
|
||||
- CONCLUSION: or-operand order (or ACC,NEW,ACC vs ACC,ACC,NEW) is set by
|
||||
the coalescer's dst-operand choice, upstream of the scheduler; phi
|
||||
ties are upstream of both. No MWCC scheduling/peephole pragma reaches
|
||||
these — source-level and pragma levers exhausted on these walls.
|
||||
|
||||
## w1011/struct2 wave-3 — or-chain serial probes
|
||||
|
||||
- `acBits = acBits | x` (explicit self-assign) produces a SERIAL
|
||||
or-chain (was pairs-tree) — but operand order still canonicalizes
|
||||
to `or ACC,ACC,NEW` regardless of textual `x | acBits` vs
|
||||
`acBits | x`. Normalized diff unchanged (25). Committed `|=`
|
||||
kept — identical score, cleaner source.
|
||||
|
||||
Reference in New Issue
Block a user