mpn_add or mpn_add_n+MPN_COPY+MPN_INCR_U ?

Torbjörn Granlund tg at gmplib.org
Sun Jun 15 12:47:01 UTC 2014


nisse at lysator.liu.se (Niels Möller) writes:

  Looks like mpn_add_n is an inline function defined in terms of
  __GMP_AORS, which does carry propagation differently. With an inline
  mpn_add, there's no good reason for it to have more overhead than
  mpn_add_N + MPN_COPY + mpn_incr_u.
  
A critical typo there, you surely mean "Looks like mpn_add is an inline
function...".

  > I'm tempted to substitute some mpn_add_1 in the code with COPY+INCR, or to
  > write a new macro NOCARRY_MPN_ADD...
  
  To me, the right way seems to be to improve the existing macrology used
  by mpn_add. 
  
I am sure these old things can be improved.

One reason for how the current mpn_add is implemented is that it is done
gmp.h and not gmp-impl.h.  We thereby don't have access to the MPN_COPY*
macros.

Perhaps we could supply different mpn_add/mpn_sub in gmp-impl.h, but
then again we should perhaps not use these internally, since they might
hide optimisation opportuneties.


Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list