Small operands gcd improvements

Torbjörn Granlund tg at
Tue Aug 13 08:05:39 UTC 2019

"Marco Bodrato" <bodrato at> writes:

  May I suggest to write:

  u0 = (u0 >> c) | (u1 << (GMP_LIMB_BITS - c));

  instead of

  u0 = (u0 >> c) || (u1 << (GMP_LIMB_BITS - c));

You may.  And it is indeed a great improvement!

The generated code for Niels' C code is awful for x86.  It consists of
mainly register-to-register copying.

We might want another C variant for machines where we don't provide
assembly.  I have written just arm32, arm64, x86-64, ppc64-power7, and
ppc64-power9 code.  I might try an x86-32 but then I'm done.

I believe an amalgamation of Niels code which uses an implicit lsb and
his present _22 code would be best.  The present requirement for
sub_mddmmss is a portability inconvenience, and for subtract-with-carry
challenged processors a major hassle.

Please encrypt, key id 0xC8601622

More information about the gmp-devel mailing list