[Bug tree-optimization/85366] Failure to use both div and mod results of one IDIV in a prime-factor loop while(n%i==0) { n/=i; }
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Apr 15 06:12:00 GMT 2018
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 ...
More information about the Gcc-bugs
mailing list