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

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #10)
> As discussed on IRC, probably the
> if (!__builtin_mul_overflow(__l._M_lo, __x, &__lo))
> optimization isn't a good idea, because most likely the compiler will in
> that case
> expand that to a full 64x64->128 multiplication plus testing that the upper
> 64 bits are or aren't zero, so computing everything this function needs and
> doing it again if there is overflow, without possibility to query what it
> computed.

Though, if it is common enough, one could try to optimize the __ll[0] == 0 &&
__xx[0] == 0 case, one can do then either 32x32->64 or 64x64->64 multiplication
and be done with it.  But if it is rare in random's usage, it would just make
the code larger.

Reply via email to