Small toom43 cleanup
tg at gmplib.org
Tue Oct 20 21:47:14 CEST 2009
bodrato at mail.dm.unipi.it writes:
> Marco, Torbjörn, does this look ok?
But I have a question:
> +mpn_toom43_mul_itch (mp_size_t an, mp_size_t bn)
> + mp_size_t n = 1 + (3 * an >= 4 * bn ? (an - 1) >> 2 : (bn - 1) /
> (unsigned long) 3);
> +static inline mp_size_t
> mpn_toom53_mul_itch (mp_size_t an, mp_size_t bn)
> mp_size_t n = 1 + (3 * an >= 5 * bn ? (an - 1) / (size_t) 5 : (bn - 1)
> / (size_t) 3);
You cast the divisor in toom43_itch to (unsigned long); toom53_itch cast
divisors do (size_t). It my last code I used a cast to (mp_size_t)...
The question is, do we really need a cast for a single digit?
It is an efficiency thing.
mp_size_t is a signed type, for various reasons. size_t is an unsigned
type. Unsigned division by constants is a few cycles faster.
Casting to "unsigned long" is not correct, it is not always large
enough. But size_t is safe.
More information about the gmp-devel