-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Failure to optimize __builtin_mul_overflow pattern #48113
Comments
assigned to @LebedevRI |
Alive2: https://alive2.llvm.org/ce/z/gi2rzw define i1 @src(i8 %0, i8 %1) { define i1 @src(i8 %0, i8 %1) { |
Fixed in 13ec913, thanks. |
Does https://reviews.llvm.org/D108928 help this get re-landed? |
Relanded in 35fa7b8. |
Extended Description
int f1(unsigned x, unsigned y)
{
unsigned int r = x * y;
return x && ((int)r / (int)x) != (int)y;
}
This can be optimized to :
int f2(unsigned x, unsigned y)
{
int res;
return __builtin_mul_overflow((int)x, (int)y, &res);
}
This optimization is done by GCC, but not by LLVM.
See also comparison here : https://godbolt.org/z/f9Yv9c
The text was updated successfully, but these errors were encountered: