-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Missed optimization for .rem_euclid(2^n) on signed integer types. #115855
Comments
If you are going to file an upstream issue yourself, please do link back to it so other people don't do duplicate work: llvm/llvm-project#66417 Anyway, this issue should already be fixed in LLVM 18. |
As an aside, the title should be 2^n (powers of two) instead of n^2 (squares). |
Thanks, wow, had a brainfart there. |
Confirmed fixed by #120055, needs codegen test. Godbolt: https://rust.godbolt.org/z/cf3Ej1Mq3 |
Fixed in 1.78.0 (Updated to LLVM 18) |
When calling
.rem_euclid(n)
on a signed integer type, it fails to apply the optimization for powers of 2, where it should do a bitwise AND operation instead.Missed optimization
How it should be optimized
Testing the optimization:
n = 2
?play
true
n = 1
?play
true
n = 4
?play
true
Curiously, the optimization is applied to unsigned integers just fine
The text was updated successfully, but these errors were encountered: