Closed
Description
Bugzilla Link | 2003 |
Resolution | FIXED |
Resolved on | Feb 20, 2008 03:13 |
Version | trunk |
OS | All |
Reporter | LLVM Bugzilla Contributor |
CC | @nlewycky |
Extended Description
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?