bodrato at bodrato at
Sun Dec 30 09:08:43 CET 2012


Il Ven, 28 Dicembre 2012 12:03 am, Niels Möller ha scritto:
> bodrato at writes:
>> About mpz_combit code, may I suggest replacing the two lines
>> 	  MPN_NORMALIZE (dp, dsize);
>> 	  ASSERT (dsize > 0);
>> with
>> 	  MPN_NORMALIZE_NOT_ZERO (dp, dsize);

> Conciseness is nice. Is that equivalent? I had some impression that the
> latter is less safe, but that may be completely wrong.

It's not a matter of conciseness, the latter is faster, but you are right:
it is not safe if the ASSERT is based on false assumptions.

In that branch, MPN_NORMALIZE_NOT_ZERO is safe (and the ASSERT is correct).

Looking deeper into, I realised that the branch-less normalization of at
most one limb is even better. The patch (for 5.2) is attached, I already
pushed specific checking code, as it can not introduce new bugs (in the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: combit.diff
Type: text/x-patch
Size: 543 bytes
Desc: not available
URL: <>

More information about the gmp-devel mailing list