Files
BFM-decomp/cookbook/C0033.md
T

4.3 KiB
Raw Blame History

§30a — §30 generalizes to the FULL near-miss backlog (via STANDARD Opus agents, not just Fable5) + 2 more steer levers + the mechanical-integration throughput unlock (Phase 23 (a))

A toolkit pass re-tested 3 backlog "store-vs-load / CONFIRMED unsteerable" verdicts with §30, run by standard Opus agents (~80–130k tokens each) APPLYING the documented idiom (not Fable5 discovering it). Result: 2 banked ×134 (func_8014F2E0 66 ins, func_80150528 53 ins; fleet 64.74→64.82%), 1 partial (func_8014EA4C 6→3 — its store-vs-load part dissolved by §30, but an orthogonal abs-coalescing/frame-fragility wall survives = genuine permuter/Fable5 territory). The "unsteerable" backlog is largely MIS-VERDICTED — these near-misses ARE matchable, and standard agents applying a GROWING toolkit crack them cheaply. Three byte-proven additions:

  1. §30 /s REFINEMENT — a cast-wrapped PLUS does NOT get /s. expr.c:5535 expr.c:4577 (guard 4570-4576, inside case INDIRECT_REF: @4540, in expand_expr @4026 — citation corrected 2026-07-28; 5535 was a gcc-2.8.1 line and points at MIN_EXPR/MAX_EXPR optab code in our 2.7.2) grants /s when the INDIRECT_REF operand is a top-level PLUS_EXPR; *(T*)(p + k) puts a NOP_EXPR (the cast) on top of the PLUS → no /s. Precision (same re-derivation): the guard is a 4-way OR, not a single test — /s is ALSO granted when the operand is a SAVE_EXPR wrapping a PLUS, when the dereferenced type is itself an aggregate (AGGREGATE_TYPE_P (TREE_TYPE (exp))), or when the pointer is an ADDR_EXPR of an aggregate. So the cast-defeats-/s rule holds for a scalar-typed deref through a plain pointer, which is the case this idiom is about — do not read it as an absolute. Only a bare-typed PLUS (q[k], q a typed T*) or a COMPONENT_REF (expr.c:5891 expr.c:4888, case COMPONENT_REF: @4748 — genuinely unconditional: the if/else above it only chooses how the address is formed, both arms fall through to the same unguarded set; NB the other MEM_IN_STRUCT_P (op0) = 1 at 4873 IS conditional (BLKmode bitfield path, returns early at 4876) and is not this one) gets it. The universal grant is the anonymous-struct member-ref ((struct{s32 f;}*)p)->f (COMPONENT_REF path), NOT *(s32*)(p+off). (byte-proven func_8014F2E0, func_8014EA4C).
  2. IV-COMBINE: keep gcc's combine_givs at N induction vars with a SINGLE base pointer. Far-field accesses off a separate q = base + off pointer make cc1 strength-reduce a spurious extra IV. Collapse to ONE base pointer with all fields as plain byte-offsets → cc1 re-combines to the target's IV count. NB: CONFLICTS with the §30 anon-struct read (which introduces a separate pointer → re-triggers the split) — read the diff and pick the lever the target's IV structure demands. (byte-proven func_80150528).
  3. INLINE LOOP-LIMIT → preheader-hoist. An invariant loop limit written as an inline expression D_x + K in BOTH the entry guard and the loop condition (NOT a cached end local) makes gcc's loop optimizer hoist it into the preheader — producing the preheader copy insn AND the target's callee-saved regalloc. A cached u8 *end local pins it in one reg = wrong. (byte-proven func_80150528).

INTEGRATION IS MECHANICAL — the throughput unlock. All 3 giants banked this session (func_8014EE14, func_8014F2E0, func_80150528) hit the SAME whole-binary near-1 after a perfect leaf match_one: a DEFINE_func_* caller macro declares the fn extern void but the matching def needs s32 (a void return DCEs a live local → frame shrinks → no match). Fix = §30 #2: widen that caller macro's extern void→s32 — byte-neutral (caller discards the return; check-all 136/136 confirms). This is TOOLABLE — a gate_stage recovery pass that, on a leaf-MATCH-but-near-1 fn, tries widening a discarding-caller-macro's extern to the def's return type would let every agent's leaf-MATCH auto-bank. Campaign implication: leaf-matching the near-miss backlog is now cheap (Opus agents + the toolkit); the bottleneck is the mechanical integration step → build the tool, then the ~95 "schedule"/80 "regalloc"/31 "hoist" backlog verdicts (many mis-labeled) become an agent-wave harvest, with Fable5 reserved for the genuinely-novel residuals (frame-fragility/coalescing walls).