Skip to content

Conversation

max-charlamb
Copy link
Member

Resolves #115661

crossgen2-comparison test comparing crossgen targeting x86 from a x86 and x64 JIT has been failing due to the x64 host JIT using different encodings.

I traced this back to a 32-bit displacement value not being sign extended to a 64-bit value. This caused the JIT to think the displacement was a large positive number and used a larger encoding.

Fixed by treating the displacement as a signed value.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a zero-extending issue in the x86_x64 JIT compiler that was causing crossgen2-comparison test failures. The issue occurred when comparing crossgen output targeting x86 from both x86 and x64 JITs, which produced different encodings due to incorrect displacement handling.

  • Changed displacement variable type from unsigned to int to properly handle sign extension
  • Ensures 32-bit displacement values are correctly sign-extended to 64-bit values instead of being zero-extended
  • Prevents the JIT from incorrectly treating displacements as large positive numbers and using inefficient larger encodings

@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 Jul 22, 2025
@max-charlamb
Copy link
Member Author

/azp list

Copy link

CI/CD Pipelines for this repository:

Copy link
Contributor

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

@max-charlamb
Copy link
Member Author

/azp run runtime-coreclr crossgen2 outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@max-charlamb max-charlamb changed the title Fix zero-extending issue on win_x86_x64 JIT Fix zero-extending displacement on win_x86_x64 JIT Jul 22, 2025
@jkotas
Copy link
Member

jkotas commented Jul 22, 2025

cc @dotnet/jit-contrib

@jkotas
Copy link
Member

jkotas commented Jul 22, 2025

@max-charlamb The JIT codebase is auto-formatted. Could you please apply the auto-formatter patch from one of the failing formatter legs?

@max-charlamb
Copy link
Member Author

/azp run runtime-coreclr crossgen2 outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crossgen2-comparison windows x86 Release to x86 windows failing for System.Private.CoreLib
3 participants