-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: Support bitwise field insertions for return registers #113178
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
JIT: Support bitwise field insertions for return registers #113178
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Incredible, thank you so much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
cc @dotnet/jit-contrib PTAL @EgorBo Diffs. Generally size and perfscore improvements. There are a number of regressions. I have looked through and written a follow-up list above -- many of them being missing constant folding in lowering. There's also some bad looking diffs from this one:
This is the cause of diffs like The underlying problem is this restriction of LSRA: runtime/src/coreclr/jit/lsra.cpp Lines 1815 to 1824 in 8a9d492
The new implementation expands returned promoted locals into |
} | ||
|
||
GenTree* folded = comp->gtFoldExprConst(node); | ||
assert(folded == node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand why it calls gtFoldExprConst here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because I didn't want to handle CAST(CNS_INT)
for all combinations here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Looking forward to seeing the same for struct args
Based on the new
FIELD_LIST
support for returns this PR adds support for the JIT to combine smaller fields via bitwise operations when returned, instead of spilling these to stack.win-x64 examples:
(the
mov eax, eax
is unnecessary, but not that simple to get rid of)An arm64 example:
(sneak peek -- this codegen requires some supplementary changes, and there's additional opportunities here)
This is the return counterpart to #112740. That PR has a bunch of regressions that makes it look like we need to support returns/call arguments first, before we try to support parameters.
There's a few follow-ups here:
FIELD_LIST
come from a promoted struct that ended up DNER. In those cases we should be able to recombine the fields back to a single large field, instead of combining them with bitwise operations.