------- Comment #12 from rguenth at gcc dot gnu dot org 2008-01-12 14:23 ------- Simplified C testcase (omitting the parts that are optimized). We cannot figure out the number of iterations of this loop:
void f(int n, float *v) { int i; if (n <= 0) return; else { i = 1; do { if (i > n) __builtin_abort (); v[i] = 0.; i++; } while (i <= n); } } Note that for this simplified testcase DOM figures out the redundant test, but not if you use i != n as the exit test, as for n == 1 the assert will trigger. If you look at the fortran IL, it does instead } while (i++ != n); which would be ok again, but is still not optimized. Testcase: extern void link_error (void); int i, n; int main() { if (i > n) return; if (i != n) if (i >= n) link_error (); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25643