mpz_invert (x, 1, 0)
nisse at lysator.liu.se
Fri Mar 2 11:14:04 CET 2012
Torbjorn Granlund <tg at gmplib.org> writes:
> Therefore, a series of disjoint unlikely conditions is not good. If
> they can be combined to few disjoint unlikely conditions (possibly
> covering some unlikely case too much, to be rejected later) that I am
> much happier. Unfortunetely, the change to invert adds such unlikely
> critical-path conditions.
Would it be an improvement to rewrite it as
xsize == 0 || (nsize <= 1 && (nsize == 0 || PTR (n) == 1))
The expression (nsize == 0 || PTR (n) == 1) can also be rewritten as
some bitwose logic. We know that nsize can be only zero or one. And if
it's one, PTR(n) can't be zero. So I think
xsize == 0 || (nsize <= 1 && ( (- (mp_limb_t) nsize) & (PTR (n) - 1)) == 0)
is a correct, if almost unreadable, test ;-)
Won't make much difference when n == 1, though, which I guess is an
What about documentation, if we choose Z0 == Z semantics because that
eliminates a branch, should we document that behaviour, or leave
inverses mod 0 undefined, in case we find some more clever conditions
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel