-
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
ARM64: Optimize a % b operation #34937
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
Jit currently always gives up on |
Yes, I have already spoke to @sandreenko about it and reverted some of the changes he did in dotnet/coreclr#18206. With that it handles the 1st case (where |
Definitely, this will not happen in .NET 6.0. |
Just noting that unlike #64591, this one is over integer types and should be safe. I'm not aware of any cases (off the top of my head) where the output could differ for Its certainly possible, however, that there is some edge case I'm not remembering or with certain variants of the instruction (there are variants that multiply, widen or narrow, and then add/subtract for example and these may have some edge case behavior depending on how they are used and other surrounding optimizations). |
We already fold |
Closing as we have finished the optimizations listed here. |
Optimize
a % b
operation for ARM64 for following scenarios:a
is unsigned int,b
is power of 2.Today we generate something like this:
We can generate:
a
is signed int,b
is power of 2.Today we generate:
We can generate:
a
is an int,b
is a variable.Today we generate:
We can generate using
msub
:Reference: https://godbolt.org/z/yxH8jZ
Reference: https://patchwork.kernel.org/patch/11126001/
category:cq
theme:optimization
skill-level:intermediate
cost:medium
The text was updated successfully, but these errors were encountered: