https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112685
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I thought I had saw this a while back. Note the Linux kernel does this kind of loop explicity to avoid the division though as the cases where it does is known to be only a few iterations (1 or 2) to get the division but the compiler does not have that information. Also I am not 100% sure this is always a win due to how slow the divide instruction is on many cores.