[Bug c/102014] [missed optimization] __uint128_t % uint64_t emits a call to __umodti3 instead of div instruction

2021-08-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102014

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Andrew Pinski  ---
Dup of bug 58897.

*** This bug has been marked as a duplicate of bug 58897 ***

[Bug c/102014] [missed optimization] __uint128_t % uint64_t emits a call to __umodti3 instead of div instruction

2021-08-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102014

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
No, that is not a safe optimization.  The x86 128-bit by 64-bit DIV instruction
will #DE if the quotient is larger than ~(uint64_t) 0, you won't get a modulo
in that case even when the modulo is guaranteed to be representable.
Consider e.g. a == b == 0x3fffULL and n == 3.