[LLVMbugs] [Bug 1253] NEW: "optimized" range comparison not simplified
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Mar 12 14:29:40 PDT 2007
http://llvm.org/bugs/show_bug.cgi?id=1253
Summary: "optimized" range comparison not simplified
Product: new-bugs
Version: unspecified
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: baldrick at free.fr
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 ; <i32> [#uses=1]
icmp sgt i32 %tmp2, -1 ; <i1>:0 [#uses=1]
zext i1 %0 to i32 ; <i32>:0 [#uses=1]
ret i32 %0
}
This would be better as: "return n<0;"
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list