-
Notifications
You must be signed in to change notification settings - Fork 787
Generalize transforms for #3153 #3193
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
Quick fuzzed:
Will fuzz it more carefully tomorrow. |
refuzzed |
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.
Can you remind me why it's not enough to just do x % -C_pot
--> x & (abs(C_pot) - 1)
? Why does the comparison with zero need to be part of the pattern?
Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com>
|
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 with that one last comment addressed :)
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.
Awesome, thanks :)
It's more general (additional) version of #3153 which also handle negative constant dividers:
(int32)x % -4 == 0
-->(x & 3) == 0
x % -C_pot == 0
-->(x & (abs(C_pot) - 1)) == 0
and special two-complement values as well:
(int32)x % 0x80000000 == 0
-->(x & 0x7fffffff) == 0
(int64)x % 0x8000000000000000 == 0
-->(x & 0x7fffffffffffffff) == 0
as separete rules:
(int32)x % 0x80000000
-->x & 0x7fffffff
(int64)x % 0x8000000000000000
-->x & 0x7fffffffffffffff
The previous pr didn't use these possibilities.
cc @kripken @tlively