Repository navigation
perf(jit): hint copies to share a register and drop them - #304
Conversation
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>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
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 |
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, vswhose source died at that row stayed a real move.asm.Frame.Copy(inst) (dst, src, ok): arm64 recognisesMOV/FMOVof one bank and width, andMOVWnarrowing X to W.freetries 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 iffitsaccepts it: the hint reorders free candidates and never changes correctness.splice(labels move to the next row).mov w1,w0; mov w2,w1→mov w1,w0; the result moves after both calls disappear).Narrowing
MOVWcounts 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-widthmov w,wremoval rests on the same fact.Evidence
TestAssembler_Buildcases: source dies, chain, float, source stays live (kept), narrowingMOVWdropped, int↔floatFMOVkept, 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.go test ./internal/... ./interp,make check,git diff --check: pass. The CI benchmark report decides the gain.Refs #239
🤖 Generated with Claude Code