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
"optimized" range comparison not simplified #1625
Comments
assigned to @lattner |
i.e. this example shows that replacing ult with slt (and presumably |
I forgot to mention where this comes from: the gcc -> llvm switch |
Fixed, testcase here: Transforms/InstCombine/xor2.ll:test[01] This handles the general case of a xor constant, not just this specific one. -Chris |
Extended Description
The condition a<=x<=b can be transformed into (unsigned)n-a<=b-a.
However if a=INT_MIN then this "optimization" leads to suboptimal
code:
#include <limits.h>
int bad (int n) {
return ((unsigned)n-INT_MIN<=-1-INT_MIN);
}
->
define i32 @bad(i32 %n) {
entry:
%tmp2 = xor i32 %n, -2147483648 ; [#uses=1]
icmp sgt i32 %tmp2, -1 ; :0 [#uses=1]
zext i1 %0 to i32 ; :0 [#uses=1]
ret i32 %0
}
This would be better as: "return n<0;"
The text was updated successfully, but these errors were encountered: