-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Optimize casts from constant byrefs #99130
base: main
Are you sure you want to change the base?
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsNoticed this was causing some missing folding with static fields in #99011.
|
src/coreclr/jit/morph.cpp
Outdated
if (oper->IsCnsIntOrI()) | ||
{ | ||
oper->gtType = TYP_I_IMPL; | ||
return fgMorphTree(gtNewCastNode(TYP_I_IMPL, oper, false, dstType)); |
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.
This might create e.g. a nongc icon handle typed as TYP_I_IMPL. I think we have a couple of asserts expecting those to be always TYP_REF. What exactly this change improves?
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.
- The cast here seems to strip handle-ness.
- Would restricting it to
TYP_BYREF
make it okay? - Added codegen diff to the PR description.
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.
- The cast here seems to strip handle-ness.
Which doesn't sound right e.g. - does it strip it for relocable (AOT) handles as well?
- Would restricting it to
TYP_BYREF
make it okay?- Added codegen diff to the PR description.
Diffs are small and are regressions so does it make sense?
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.
Which doesn't sound right e.g. - does it strip it for relocable (AOT) handles as well?
Made it retype the handles instead.
Diffs are small and are regressions so does it make sense?
The only diff currently is from a GC hole that's fixed in #99138, I'd guess this won't have any diffs in the BCL or tests outside of #99011 since those don't generally use AsPointer on statics or RVA statics.
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.
It's nice that it helped you to find a gc hole! No diff in BCL means it's basically untested, it's probably fine now but may fail in future if we introduce byref icon handle? I think we should do changes like these only if they provide clear benefits and risks are understood
Found in dotnet#99130.
* Fix GC hole in Guid Found in #99130. * Add missing in --------- Co-authored-by: Stephen Toub <[email protected]>
We don't have time to work on this for .NET 9, so we will review it in .NET 10. |
Noticed this was causing some missing folding with static fields in #99011.
Sample codegen:
Before:
After:
With a static field happening to be aligned: