https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Once undefined behavior happens all bets are off of any behavior of the program. In this case the function is in lined and the optimizers see i cannot overflow the multiply so it removes the loop check.