[LLVMbugs] [Bug 1598] New: miscompilation of if(expr){ do{...}while(expr2) }
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Aug 4 16:21:16 PDT 2007
http://llvm.org/bugs/show_bug.cgi?id=1598
Summary: miscompilation of if(expr){ do{...}while(expr2) }
Product: libraries
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: Loop Optimizer
AssignedTo: unassignedbugs at nondot.org
ReportedBy: nicholas at mxc.ca
CC: llvmbugs at cs.uiuc.edu
Consider this C program:
int f(int a, int b, int x, int y) {
if (a != b) {
do {
++x;
} while (x < y);
}
return x;
}
Currently, this generates:
define i32 @f(i32 %a, i32 %b, i32 %x, i32 %y) {
entry:
%tmp3 = icmp eq i32 %a, %b
%retval = select i1 %tmp3, i32 %x, i32 %y
ret i32 %retval
}
which is pretty seriously funny. The bug in this case is ScalarEvolution's
HowManyLessThans search for a dominating comparison. If the comparison is for
EQ or NE then it doesn't bother to check the arguments at all.
Although the search for a dominating comparison is a good fallback, this
function should probably be changed to check whether the initial iteration of
the loop matches the condition or not using AddRec::getStart and such.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list