-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[JIT] X64 - Peephole optimization to skip emitting movsxd
#81721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue Detailsnull
|
GT_CAST for long to small types on 64bitGT_CAST for long to small types on 64bit
GT_CAST for long to small types on 64bitmovsx
movsxmovsxd
Contributor
Author
|
@dotnet/jit-contrib @BruceForstall - no regressions, decent number of improvements - should be a quick and easy review |
tannergooding
approved these changes
Feb 7, 2023
This was referenced Feb 8, 2023
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When I allowed
LONGtypes in #81454 , I noticed some regressions. They were caused by the IR tree looking like this:CAST(long <- CAST(int <- short <- long))On x64, this would emit:
The
movsxdis redundant asmovsxhas already sign-extended to 8 bytes and we only ever emitmovsxas an 8-byte operation; there will never be a case where we emitmovsx edx, cxon 64-bit. Therefore, we can skip emittingmovsxdif we know the previous instruction sign-extended the register all the way to 8 bytes.Example diffs:
imul rdx, rdx, 60 sub rcx, rdx movsx rdx, word ptr [rbp-40H] - movsxd rdx, edx imul rdx, rdx, 60 mov r8, 0xD1FFAB1E cmp rdx, r8 jg G_M18963_IG34 - ;; size=182 bbWeight=0.50 PerfScore 18.88 + ;; size=179 bbWeight=0.50 PerfScore 18.75The
cdqeinstruction is simply an optimization for size when trying to emitmovsxd rax, eax- so it's expected that this was also skipped.Acceptance Criteria