https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85366
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- For GCC 7.3 on aarch64: ;; _23 = n_26 % i_30; (insn 83 76 84 (set (reg:SI 142) (udiv:SI (reg/v:SI 117 [ n ]) (reg/v:SI 115 [ i ]))) "t88.c":6 -1 (nil)) (insn 84 83 85 (set (reg:SI 143) (mult:SI (reg:SI 142) (reg/v:SI 115 [ i ]))) "t88.c":6 -1 (nil)) (insn 85 84 0 (set (reg:SI 116 [ _23 ]) (minus:SI (reg/v:SI 117 [ n ]) (reg:SI 143))) "t88.c":6 -1 (nil)) This is because the range of n_26 is positive only: # RANGE [2, 2147483647] NONZERO 2147483647 But we know that here both div and udiv will return the same result ...