Small limb-size in mini-gmp?

Niels Möller nisse at
Tue Nov 19 21:20:51 UTC 2019

"Marco Bodrato" <bodrato at> writes:

> Ciao,
> Il Mar, 19 Novembre 2019 7:50 pm, Torbjörn Granlund ha scritto:
>> If there is special code for several asl cases, doesn't that defeat the
>> purpose of asl, at least to some extent?

I think it defeats small-limb testing of mini-gmp. If it makes mini-gmp
with small limbs much faster, it might aid small-limb tests of mpfr.

> It is possible (and not really difficult, I think) to adapt the default
> code and remove any special shortcut from both those functions too.

When the special code was added (about a year ago, 2018-12-21), was that
as an optimization, or because the original code didn't work properly
for small limb size?

I think there are assumptions at some places that unsigned int is large
enough to hold half a limb (e.g., temporaries in umul_ppmm). Should be
no problem for unusually *small* limb size, but might make sense to use
mp_limb_t for all variables representing half limbs. Should also make
some of the casts unnecessary.

> I think that special code to use plain unsigned long multiplication and
> plain unsigned long division for those two critical macros, when limbs are
> small enough, is a reasonable compromise.

Maybe for umul_ppmm, but I disagree about mpn_invert_3by2. The latter
function isn't used in any inner loops.

>> (Testing was successful now.  Let me know if mati's weekly testing is
>> sufficient or if additional or more frequent testing would be

I think weekly tests should be adequate for now.


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