mpn_perfpow: do we need a special GCD for mp_bitcnt_t?

bodrato at bodrato at
Mon Sep 1 20:00:11 UTC 2014


Il Lun, 1 Settembre 2014 2:40 pm, Torbjörn Granlund ha scritto:
> nisse at (Niels Möller) writes:

>   > examined number, the exponent is returned as mp_bitcnt_t, the returned
>   > value is then casted to mp_limb_t, because we need the GCD of the
>   > exponents and mpn_gcd_1 wants limbs.
>   And when can there be a problem? If the mp_limb_t type is smaller than
>   mp_bitcnt_t?

> I am not aware of any configurations where mp_limb_t is the smaller of
> the two.  But I feel bothered by type mixing such as this.

Mixing types is not good for abstraction, i.e. portability and

>   Vaguely related: We could have an mpn_gcd_11 function, accepting two
>   limb-size arguments.
> Which would then be in assembly.  This would obsolete the many mpn_gcd_1
> implementations, I think.

There are at least two functions where mpn_gcd_11 is needed and currently
mpn_gcd_1 (&x, 1, y) is used:
$ grep -rl "mpn_gcd_1 (&" mp?

... in both cases, to be honest, the GCD is needed on arguments that are
not limbs...



More information about the gmp-devel mailing list