Small toom43 cleanup
Torbjorn Granlund
tg at gmplib.org
Wed Oct 21 08:44:49 CEST 2009
bodrato at mail.dm.unipi.it writes:
> 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.
Ok, but in all cases we have
mp_size_t bn;
mp_size_t n = (bn-1) / (cast type) 3;
Does the compiler know that (bn-1) is unsigned positive? I do not think so...
I don't understand what you mean by "unsigned" here.
Surely the compiler does not know that bn-1 >= 0.
Will it compile a signed or an unsigned division?
Unsigned, if it is a standards conforming C compiler.
Maybe it is better to cast the other side:
mp_size_t n = ((unsigned type)bn-1) / 3;
That should be equivalent.
and let the compiler decide the best type for the small constants 1 and 3 ?
The type of 3 is "signed int".
--
Torbjörn
More information about the gmp-devel
mailing list