Skip to content

Conversation

@tannergooding
Copy link
Member

@tannergooding tannergooding commented Jul 8, 2025

This is a follow up from #117288 where I noticed a lot of complexity in how emitInsSizeSV handled it's logic and some variance between it and emitOutputSV.

There are a decent number of places where we have smaller size predictions and so allocate less bytes for the method. There are likewise a miniscule number of places where we actually emit smaller instructions based on the predictions:

Windows x64

Overall (-760 bytes)
MinOpts (-740 bytes)
FullOpts (-20 bytes)

Linux x64

Overall (-23 bytes)
MinOpts (+0 bytes)
FullOpts (-23 bytes)

However, there is a significant throughput improvement across the board due to the reduced complexity:

Windows x64

Overall (-0.18% to -0.01%)
MinOpts (-0.43% to -0.15%)
FullOpts (-0.03% to -0.01%)

Linux x64

Overall (-0.01% to +0.00%)
MinOpts (-0.08% to +0.00%)

Windows x86

Overall (-0.08% to -0.01%)
MinOpts (-0.23% to -0.10%)
FullOpts (-0.02% to -0.01%)

@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 8, 2025
@dotnet-policy-service
Copy link
Contributor

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

@tannergooding tannergooding marked this pull request as ready for review July 8, 2025 19:41
Copilot AI review requested due to automatic review settings July 8, 2025 19:41
Copy link
Contributor

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 refactors emitInsSizeSVCalcDisp to unify prefix and displacement size calculations and align them with emitOutputSV logic.

  • Consolidates separate prefix (emitGetAdjustedSize/REX) and displacement sizing into a single pass
  • Simplifies local vs. parameter frame‐offset computation
  • Integrates EVEX and VEX displacement compression handling
Comments suppressed due to low confidence (2)

src/coreclr/jit/emitxarch.cpp:5154

  • Add unit tests covering both successful and failed EVEX compression paths (i.e., when TryEvexCompressDisp8Byte returns true and false) to ensure dspInByte and overall returned sizes are correct.
            if (TryEvexCompressDisp8Byte(id, dsp, &compressedDsp, &dspInByte))

src/coreclr/jit/emitxarch.cpp:5113

  • The original handling for temporary locals (when var < 0) has been removed; you need to reintroduce that branch or handle temps explicitly to avoid breaking frame offset calculations for stack temps.
    int  adr;

@tannergooding
Copy link
Member Author

CC. @dotnet/jit-contrib. This is ready for review, it is both a small simplification to the xarch emitter and an improvement (across the board) to both code size and throughput.

@tannergooding tannergooding merged commit f223627 into dotnet:main Jul 9, 2025
114 of 115 checks passed
@tannergooding tannergooding deleted the emitInsSize branch July 9, 2025 01:10
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2025
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.

2 participants