-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improved RuntimeHelpers.ConvertLength codegen #3608
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
Conversation
Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
Hello @michael-hawker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
@RosarioPulella want to take a quick look? 😉 @Sergio0694 always another instruction to remove, eh? |
@michael-hawker Ahahah always! Trying to make the 7.0 release of the |
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.
Love it! I never knew that the division of uint
s has so many less instructions than int
s
Also I see he |
@RosarioPulella Yup, it's ready to go! The bot added that label automatically when I put this PR into the 7.0 milestone 🙂 |
Follow up from #3520
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The codegen for the second branch in
RuntimeHelpers.ConvertLength
does a signed division:https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/9b75c9f910f999834c64bd00e522d7ae464c121b/Microsoft.Toolkit.HighPerformance/Helpers/Internals/RuntimeHelpers.cs#L43-L46
This is not the best for the codegen, as the JIT has to handle the sign in that division, resulting in the following:
What is the new behavior?
Avoided that with a cast to
uint
, since the length is guaranteed to be a positive value in[0, int.MaxValue]
anyway:Perfect! 😄🎉
PR Checklist
Please check if your PR fulfills the following requirements:
Pull Request has been submitted to the documentation repository instructions. Link:Sample in sample app has been added / updated (for bug fixes / features)Icon has been created (if new sample) following the Thumbnail Style Guide and templates