Skip to content

arm64: Avoid unused vector constant temps and prefer no-op casts - #136705

Merged
tannergooding merged 3 commits into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-vector-temps
Nov 25, 2026
Merged

tannergooding merged 3 commits into
dotnet:mainfrom
jonathandavies-arm:upstream/opt/arm64-vector-temps

Conversation

@jonathandavies-arm

Copy link
Copy Markdown
Contributor

Match the vector immediate checks when building register requirements, so encodable constants do not reserve an unused integer temporary. Prefer the source register for non-overflowing int-to-int casts that can be elided when source and destination share a register.

SuperPMI asm diffs against main (294b271), using Release JITs and six published Linux ARM64 collections, show 184 fewer generated code bytes. Of 60 changed compilation contexts, 45 became smaller and none grew.

- Related to dotnet#136694

Match the vector immediate checks when building register requirements,
so encodable constants do not reserve an unused integer temporary.
Prefer the source register for non-overflowing int-to-int casts that
can be elided when source and destination share a register.

SuperPMI asm diffs against main (294b271), using Release JITs and
six published Linux ARM64 collections, show 184 fewer generated code
bytes. Of 60 changed compilation contexts, 45 became smaller and none
grew.
@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 Oct 30, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 30, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 7 pipeline(s).
9 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.

@JulieLeeMSFT JulieLeeMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The new canEncode check in LSRA matches CodeGen::genSetRegToConst: same is8 SIMD8/SIMD16 split and the same i32/i16/i8 MOVI checks.

The int temp is reserved only when codegen takes the memory-load fallback (emitIns_R_C).

The int -> int cast change is consistent with the existing long -> int handling.

Optionally, a shared helper for the MOVI check would remove the duplication, but that can be a follow-up.

Comment thread src/coreclr/jit/lsraarm64.cpp Resolved
@SwapnilGaikwad SwapnilGaikwad mentioned this pull request Nov 5, 2026
2 of 27 tasks
@SwapnilGaikwad

Copy link
Copy Markdown
Contributor

Hi @tannergooding , is there anything we can do to push this further?

@tannergooding

Copy link
Copy Markdown
Member

/ba-g unrelated timeout

@tannergooding
tannergooding merged commit 2afc501 into dotnet:main Nov 25, 2026
133 of 136 checks passed
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.

4 participants