[Bug target/85791] multiply overflow (128 bit)

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 15 15:52:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85791

--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Ruslan Nikolaev from comment #0)
> 2. unsigned long long func(unsigned long long a, unsigned long long b)
> {
>         __uint128_t c = (__uint128_t) a * b;
>         if (c > (unsigned long long) -1LL) {

It should not be too hard to recognize in GIMPLE the case of a widening mul of
unsigned numbers that has only 2 uses, one narrowing, the other comparing to
this constant (or to a widened version of the narrowed value, or extracting the
high part and comparing it to 0, etc).

Independently, it may be possible to teach RTL/target that some mul+cmp+jump is
equivalent to mul+jmp.


More information about the Gcc-bugs mailing list