Suggested mpn/generic/gcd.c patch

Niels Möller nisse at lysator.liu.se
Mon Sep 9 20:07:26 UTC 2019


tg at gmplib.org (Torbjörn Granlund) writes:

> This patch gets rid of the gcd_1 call and instead handles everything
> with gcd_11 and gcd_22.  It also lifts the operands into registers.
>
> Niels, do you agree with this?  Marco?

Looks right to me.

> We discussed a gcd_21 in the past, and here again is a utility for it.
> It is behind an UNLIKELY just as it is unlikely within gcd_22, so not
> super important.

Not that important. If we implement it, the typical case (when it's
used at all), will have it run for only one or two iterations before
calling gcd_11.

If we add any more functions, I think it's better to do variants of
gcd_11 and gcd_22 that allow one argument even.

> Perhaps gcd_21 is more common as operands directly from user code.

If we get u and v of different size from the user, we do an initial
reduction. So I don't think it will end up here.

> --- 218,261 ----
>     ASSERT(up[n-1] | vp[n-1]);
>   
> !   /* Due to the calling convention for mpn_gcd, at most one can be even. */

This is the statement not quite agreeing with the docs, as discussed a
while ago.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list