Why set zero in zero.c rather than use xor_n

Torbjörn Granlund tg at gmplib.org
Mon Feb 5 20:48:47 UTC 2018

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

  It looks like internally we use the MPN_ZERO and MPN_FILL macros. The
  mpn_zero function is not inlined, as far as I see.

  > I am not sure it is important enough to write in asm, though.
  Probably not. But it might make sense to rewrite as a wrapper for
  memset, which I'd expect to be well optimized in gcc and libc.
I suppose memset is not used as it might come with more overhead for
checking alignment.  I haven't timed it, though.

(I checked the C version of memset in glibc.  Curiously, this is my old
code from 1991.  It uses a hardwired cutoff point of 8 bytes for
invoking non-trivial code.  That'd help.  Not sure if the asm code for
various CPUs do similarly.)

Please encrypt, key id 0xC8601622

More information about the gmp-devel mailing list