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

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #11)
> 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.

We will only use this new type when the calculation a*(m-1)+c doesn't fit in 64
bits, and the input values should be uniformly distributed in [0,m) for a good
choice of parameters (and for a bad choice of parameters, you have bigger
problems than the calculation being slow!)

For a small value of a and large value of c we would use this new type but the
multiplication step would overflow infrequently, but I don't think that's a
good choice of parameters and not worth optimizing for.

So I think we should just use the full 64x64 multiplication unconditionally.

For operator% the if (__l._M_hi == 0) branch is probably worth it, because the
general case is so much more expensive.

Reply via email to