Skip to content

arm64: Fix wrapped consecutive-register spill scoring - #137244

Open
jonathandavies-arm wants to merge 1 commit into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-consecutive-spill-scoring
Open

jonathandavies-arm wants to merge 1 commit into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-consecutive-spill-scoring

Conversation

@jonathandavies-arm

Copy link
Copy Markdown
Contributor

Wrapped vector registers start at REG_FP_FIRST in the register mask. Shift the wrapped part of each candidate's mask accordingly so free registers are counted correctly. For V30, V31, V0, V1, use bits 62, 63, 32, 33 instead of 62, 63, 0, 1. This avoids unnecessary spills.

Performance

The targeted SpillProbe.Run reproducer repeatedly calls a method with high
vector-register pressure and a four-register table lookup. I compared ARM64
Release JITs built from the same mainline revision, with only this fix differing.
Both used the same runtime and CoreLib. Each measurement made 40 million calls, with ReadyToRun and tiered compilation disabled. Ten rounds
interleaved the baseline, fix, and a second baseline run as a control. The
figures below are medians; hardware counters cover the whole process.

Metric Baseline Fix Baseline control Change
Elapsed time 383.106 ms 350.310 ms 382.186 ms -8.56%
Cycles 1.6454 billion 1.5164 billion 1.6422 billion -7.84%
Instructions 3.9777 billion 3.8570 billion 3.9782 billion -3.04%

All runs returned the same checksum. For this workload, the generated
SpillProbe.Run method shrank from 280 to 268 bytes. These measurements
describe the targeted reproducer rather than a general application workload.

- Related to dotnet#136694

Wrapped vector registers start at REG_FP_FIRST in the register mask.
Shift the wrapped part of each candidate's mask accordingly so free
registers are counted correctly. For V30, V31, V0, V1, use bits 62,
63, 32, 33 instead of 62, 63, 0, 1. This avoids unnecessary spills.

Repeated runs of the SpillProbe.Run test showed 8.56% less elapsed
time, 7.84% fewer cycles, and 3.04% fewer instructions.
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 10, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 10, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 7 pipeline(s).
8 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@SwapnilGaikwad

Copy link
Copy Markdown
Contributor

cc: @dotnet/arm64-contrib @dhartglassMSFT

This branch has not been deployed

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

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants