[LLVMbugs] [Bug 2003] New: Incorrect iteration count for loop with unsigned ICMP condition
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Feb 9 15:05:42 PST 2008
http://llvm.org/bugs/show_bug.cgi?id=2003
Summary: Incorrect iteration count for loop with unsigned ICMP
condition
Product: libraries
Version: trunk
Platform: All
OS/Version: All
Status: NEW
Keywords: miscompilation
Severity: normal
Priority: P2
Component: Global Analyses
AssignedTo: unassignedbugs at nondot.org
ReportedBy: wmatyjewicz at fastmail.fm
CC: nicholas at mxc.ca, llvmbugs at cs.uiuc.edu
For the following LLVM code:
define void @foo(i32 %n) {
entry:
br label %header
header:
%i = phi i32 [ 100, %entry ], [ %i.inc, %next ]
%cond = icmp ult i32 %i, %n
br i1 %cond, label %next, label %return
next:
%i.inc = add i32 %i, 1
br label %header
return:
ret void
}
which contains loop of this form:
unsigned n = ...;
for (unsigned i = 100; i < n; ++i)
;
scalar evolution determines loop iteration count as: (-100 + %n).
This isn't correct, because for %n < 100 we'll get negative number of
iterations.
One way to fix it is to add a 'umax' SCEV similar to the 'smax' one. Using it,
the answer for the example would be: (100 umax %n) - 100.
Any other ideas?
--
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