https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88844
Bug ID: 88844 Summary: poor range info for number of loop iterations with a known upper bound Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The number of iterations of the loop below is bounded by the size of i so the value of n on loop exit is in the range [0, 4] but get_range_info() reports it as [0, +INF]. As a result, the if statement is not eliminated. void f (unsigned i) { unsigned n = 0; while (i) { i >>= 4; ++n; } if (n > sizeof i) __builtin_abort (); }