mpn_mul is embarrassingly slow

Torbjörn Granlund tg at
Tue Apr 24 13:24:09 UTC 2018

paul zimmermann <Paul.Zimmermann at> writes:

  I would entirely drop all the squaring-related stuff from mpn_mul:
  the user/developer should call mpn_sqr instead (see my previous mail).

That's tempting, but a 30% slowdown on some user code would not be nice.

  (I believe it is vn and not un that should be compared to MUL_TOOM22_THRESHOLD.)

The comment added before that "if" statement motivates why un is used:

/* If un, and thus vn, are below the toom22 range, drop into mul_basecase.
   Test un and not vn here not to thwart the code handling un >> vn below. */

Please encrypt, key id 0xC8601622

More information about the gmp-devel mailing list