Skip to content

JIT: Use smaller xarch mov encoding when long fits into int - #135182

Open
BoyBaykiller wants to merge 4 commits into
dotnet:mainfrom
BoyBaykiller:xarch-sign-extending-mov
Open

BoyBaykiller wants to merge 4 commits into
dotnet:mainfrom
BoyBaykiller:xarch-sign-extending-mov

Conversation

@BoyBaykiller

Copy link
Copy Markdown
Contributor

Fixes #134012

@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 4, 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 4, 2026
@azure-pipelines

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

@BoyBaykiller
BoyBaykiller marked this pull request as ready for review October 4, 2026 19:59
Comment thread src/coreclr/jit/emitxarch.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new encoding path lacks regression coverage for emitted bytes, size, and boundary values.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Optimizes x64 JIT code size by using the 7-byte sign-extending C7 encoding when a 64-bit immediate fits in int32_t.

Changes:

  • Selects and sizes the shorter encoding.
  • Emits mov r/m64, imm32.
  • Uses FitsIn<int32_t> for validation.
File Description
src/​coreclr/​jit/​emitxarch.cpp Implements the shorter immediate encoding.

Comment on lines +16967 to +16968
bool isSignExtendingMov = (size == EA_8BYTE) && FitsIn<int32_t>(val) && !id->idIsCnsReloc();
if ((ins == INS_mov) && isSignExtendingMov)

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.

JIT: Shorter x64 encoding for all 32bit negative immeds moved into 64bit register

3 participants