Skip to content

[0.32][Backend] Evaluate register retention and helper scratch reuse #39

Closed

Description

@a19q3

Follow-up to #34 and D5. Scalar stack-slot reuse is implemented in 0.31; register retention and helper-scratch reuse are separate work. The maintainer promoted this finite evaluation into the 0.32 completion scope on 2026-10-04. Candidate adoption remains conditional on measured evidence; rejecting a measured candidate and retaining the existing backend is a valid evaluation outcome. The October 3 independent-review waiver covers this cost-research work, but does not waive frozen budgets, checker agreement or required gates.

Choose a bounded local register-retention experiment before considering a general allocator. Treat helper-scratch ownership as an independent decision.

Acceptance:

  • Define live-register sets, helper/call clobbers, address-exposed exclusions and conservative fallbacks.
  • Test joins, backedges, overlapping operands, calls, wide fixed bytes and outgoing arguments.
  • Measure static loads/stores and executed traffic where instrumented; report ELF, cycles and stack independently.
  • Preserve source-map/checker claims without deriving lifetimes from offsets alone.
  • Record tradeoffs explicitly, preserve fixed budgets, and run backend and CI gates.

Activity

  1. added this to the 0.32 milestone on Oct 3, 2026
  2. changed the title [-][Post-0.31][Backend] Evaluate register retention and helper scratch reuse[/-] [+][0.32][Backend] Evaluate register retention and helper scratch reuse[/+] on Oct 4, 2026
  3. a19q3 commented on Oct 5, 2026

    @a19q3
    CollaboratorAuthor

    0.32 evaluation progress; keeping this issue open until the additional replay archive is published.

    The retained research baseline already records the first binary-left retention candidate: 1,707 unchanged executions. A second, separately archived local experiment now exercises adjacent scalar LoadConst/LoadVar producers and right-operand reuse, with explicit live-register avoid sets. It invalidates retention at calls/unclassified instructions and block boundaries, and preserves stores, parameter spills, wide/resource/borrow/address exclusions and outgoing arguments.

    Results: 35 identical-IR probe pairs passed (25 save one cycle, ten tie); the complete 6,782-metric comparator has zero regressions; 1,707 paired scheduler traces have four one-cycle improvements and 1,703 ties. The changed executions are valid/rejection paths for scalar-overlap-64 and scalar-overlap-260: one fewer executed LD, one extra register-move ADDI, and unchanged ELF bytes, stores and observed stack.

    Decision: reject this candidate for the 0.32 default because that measured benefit does not justify another cross-instruction register contract. Retain conservative helper-scratch ownership. This does not establish that broader retention is useless, and no general allocator or scratch reuse is implemented by this evaluation. The candidate is isolated from the implementation branch; no full candidate backend/CI pass is claimed.

    The pending archive contains both exact dirty-source replay patches, baseline/candidate main and multi-Script reports, full attribution traces, comparisons and hashes. Publication and final evidence links remain outstanding; this comment is a progress record, not a closure or release claim.

  4. a19q3 commented on Oct 10, 2026

    @a19q3
    CollaboratorAuthor

    Completed within the 0.32 implementation scope. This closes the bounded register-retention and helper-scratch evaluation with explicit measured reject/retain decisions; it is not a release or public-deployment claim, and it does not implement a general allocator, dead-store elimination, parameter-spill coalescing or scratch reuse.

    • Live-register contract: the candidate retains one SSA value in t0 between adjacent instructions in one basic block, in functions already admitted by conservative scalar-slot allocation above optimization level zero. Calls and unclassified instructions invalidate the fact; block-local state cannot cross joins/backedges; explicit avoid sets protect a retained operand during large-offset loads. Wide/resource/borrow/address-exposed exclusions, parameter spills, all stores and outgoing arguments are unchanged. The pre-implementation contract docs/CELLSCRIPT_SCALAR_RETENTION_EXPERIMENT.md is embedded in both replay patches.
    • Coverage: 35 identical-IR paired probes cover subtraction/division/remainder/shifts with exact failure paths, signed/narrow normalization, overlapping values, duplicate SSA operands, joins/backedges, a preserved local call, nine outgoing arguments, wide-value fallback and a frame larger than 2,048 bytes.
    • Independent reporting: the complete 6,782-metric comparator passes with zero regressions; 1,707 paired scheduler traces give four one-cycle improvements and 1,703 ties, confined to scalar-overlap-64 and scalar-overlap-260. Changed rows show one fewer executed LD and one extra ADDI move with unchanged ELF bytes, static stores and observed stack. ELF, cycles and stack are reported separately; per-case values are not frequency-weighted savings.
    • Source-map/checker claims: no machine contract changed. The retained default preserves source maps and checker agreement; the duplicate-SSA probe's typed-IR mutation is identified in its report rather than claimed as source equivalence.
    • Decision: reject both candidates (the first binary-left-only candidate had 1,707 unchanged executions). One cycle on two scalar fixtures does not justify another cross-instruction producer/consumer register contract. Conservative helper-scratch ownership is retained; wider reuse stays blocked on explicit helper clobber/live-register contracts and proved-removable dead parameter spills.
    • Gates: the candidate is isolated and no full candidate backend/CI pass is claimed. The retained implementation passes dev, strict-full backend (with pinned CKB stateful acceptance) and ci at clean 6a453d3015784784a27ba1aa0a4b6b1a73db79a8 (validation.json); the resumed replay re-verified all twenty archive files and replayed the native comparator at 6dba1768 with no regression.
    • Published archive: retention-second contains both exact dirty-source replay patches, baseline/candidate main and multi-Script reports, attribution traces, comparisons, logs and hashes, with reproduction commands.
  5. a19q3 commented on Oct 10, 2026

    @a19q3
    CollaboratorAuthor

    Closing as completed: both bounded register-retention candidates measured and rejected, helper-scratch ownership retained, archive published and replay-verified. Evidence: #issuecomment-6099388124.

  6. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions