Skip to content

perf(jit): hint copies to share a register and drop them - #304

Merged
siyul-park merged 2 commits into
mainfrom
perf/jit-move-hints
Nov 9, 2026
Merged

siyul-park merged 2 commits into
mainfrom
perf/jit-move-hints

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Summary

Step 4 of the #239 call-cost plan. The allocator picked the first free register with no knowledge of copies, so a MOV vd, vs whose source died at that row stayed a real move.

  • asm.Frame.Copy(inst) (dst, src, ok): arm64 recognises MOV/FMOV of one bank and width, and MOVW narrowing X to W.
  • free tries the copy partner's register first (the source of the copy at the interval's first row when the source dies there; the destination of the copy at its last row when that value starts there), only if fits accepts it: the hint reorders free candidates and never changes correctness.
  • Copy rows whose two sides received one register are dropped through the existing splice (labels move to the next row).
  • recursive-fib-20 tier-2: 132 → 129 instructions (entry mov w1,w0; mov w2,w1 → mov w1,w0; the result moves after both calls disappear).

Narrowing MOVW counts as a copy because no consumer relies on a 32-bit value's upper half: boxing (ubfx), indexing (sxtw) and addressing (sbfx) extend explicitly, and same-width mov w,w removal rests on the same fact.

Evidence

  • TestAssembler_Build cases: source dies, chain, float, source stays live (kept), narrowing MOVW dropped, int↔float FMOV kept, fixed source, fixed destination, hint blocked by a fixed register (kept), labels rebased past a dropped copy. Six fail with the hint disabled.
  • TestArch_Copy.
  • No existing arm64 or compile golden changed.
  • go test ./internal/... ./interp, make check, git diff --check: pass. The CI benchmark report decides the gain.

Refs #239

🤖 Generated with Claude Code

The allocator picked the first free register with no knowledge of
copies, so a MOV whose source died at that row stayed a real move. The
Frame now recognises plain copies (Copy: MOV/FMOV of one bank and
width, or MOVW narrowing X to W), free tries the copy partner's
register first when it fits, and copy rows whose two sides received
one register are dropped through splice. The hint only reorders free
candidates. recursive-fib-20's optimized code loses three moves.

Narrowing MOVW counts as a copy because a 32-bit value's upper half is
never relied on: boxing, indexing and addressing extend explicitly.

Refs #239

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c94a1d57-620e-4052-aea7-2df7af988221
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@siyul-park

Copy link
Copy Markdown
Owner Author

CI A/B (on bbaa056): spectral-norm −8.9%, i64-wide-fib −6.8%, tail-ping-pong −6.4%, recursive-fib −5.4%, indirect-recursive-fib −5.4%, sieve −4.8%, fnv1a64 −4.2%; geomean −0.56%.

n-body +16% and typed-array-sum +9.6%: n-body's base is ±19% on this runner. typed-array-sum's loop keeps the same instruction count (the two back-edge copies only change registers); its start moves 12 bytes. A local interleaved A/B (6 rounds, min) shows typed-array-sum 180.0 → 167.7 ns, n-body +1.6%, sort-stress +0.9%. Read as loop-alignment layout effects, not extra work.

coverage failed once on TestPool_Get/pooled interpreters alternating Runs publish code after about threshold total entries (18 > 16, background-compile timing); the rerun passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant