-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Eliminate chained casts to small types #52561
Conversation
00bc131
to
2d887bc
Compare
2d887bc
to
0890b03
Compare
0890b03
to
f96082d
Compare
We can take advantage of the implicit zero/sign-extension for small integer types and eliminate some casts.
f96082d
to
4d1371f
Compare
Marking as ready for review. Final diffs: SPMI Windows x64
SPMI Windows x86
SPMI Linux ARM64
Sample improvement: G_M38819_IG02:
- movzx r8, r8w
movzx r8, r8b
- movzx rdx, dx
movzx rdx, dl
G_M38819_IG03:
jmp System.Xml.XmlStreamNodeWriter:WriteBytes(ubyte,ubyte):this Regressions are coming from lost CSE opportunities, where previosly we had X |
cc @sandreenko as this is a morph change. |
PTAL @dotnet/jit-contrib |
Ping to keep the bot happy. |
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.
LGTM, sorry for the long wait!
{ | ||
goto REMOVE_CAST; | ||
} | ||
// We can take advantage of the implicit zero/sign-extension for | ||
// small integer types and eliminate some casts. | ||
if (opts.OptimizationEnabled() && !oper->gtOverflow() && !gtIsActiveCSE_Candidate(oper) && |
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.
I had a question about why we don't do it for not small type but you already addressed it in the header :-)
We can take advantage of the implicit zero/sign-extension for small integer types and eliminate some casts.
Diffs as of first commit. Regressions are caused by losing some CSEs
Draft until:
1)
Formatter is happy.2)
Regular CI is happy.3)
Investigation into special-casing local variables normalized on load to avoid regressions is complete.- most of the improvements are coming from this, so it is a trade-off.4)
Investigation into generalizing this for larger types and/or checked casts is complete- I will be refactoringfgMorphCast
some more in the (hopefully near) future, so out of scope for now.