Compare commits
11 Commits
main
...
agent/w100
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d630361de | ||
|
|
ef3e9df9dc | ||
|
|
587d640ddf | ||
|
|
60f6583e56 | ||
|
|
183c61ace2 | ||
|
|
d2a123cc06 | ||
|
|
00b26b2e79 | ||
|
|
de4c63b4df | ||
|
|
e02ee681ba | ||
|
|
641927194a | ||
|
|
378258fcdb |
@@ -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,9 +199,21 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
}
|
||||
nonKana:
|
||||
if (mTranslateMode == 3) {
|
||||
CharacterOutput output(input);
|
||||
output.append(ch);
|
||||
count = output.finish();
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -28,3 +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.
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
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).
|
||||
|
||||
## 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).
|
||||
|
||||
`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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user