https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69526
--- Comment #3 from amker at gcc dot gnu.org --- (In reply to rdapp from comment #2) > Ok, that's sensible but why is the - 1 necessary in the first place? > > n_5 - 1 can only underflow if n_5 == 0 which is checked by > > testl %edx, %edx > > before. This is in a previous basic block, unfortunately, and will not be > regarded by ivopts then (because strictly speaking, it has no influence on > the induction variable)? yes, one way out is use loop preconditions to improve range information and then use that info to prove non-overflow. This has already been applied to loop niter analysis and scev overflow check. I once opened a PR about this in items of loop header bloated issue. (will update the PR number cause I don't have it now). Another point is I think Richard planned to improve range analysis wrto control flow? It could be helpful here in items of compilation time.