https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101145
Bug ID: 101145 Summary: niter analysis fails for until-wrap condition Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- unsigned foo(unsigned val, unsigned start) { unsigned cnt = 0; for (unsigned i = start; i > val; ++i) cnt++; return cnt; } fails niter analysis. At least for the following variant the number of iterations should be about UINT_MAX - start. unsigned foo(unsigned val, unsigned start) { unsigned cnt = 0; if (start > val) { unsigned i = start; do { cnt++; } while (++i > val); } return cnt; }