Squaring optimization in mpz_addmul/mpz_submul

Fredrik Johansson fredrik.johansson at gmail.com
Wed May 25 22:48:14 CEST 2022


Hello GMP developers,

Now that mpn_mul no longer dispatches to mpn_sqr, the squaring optimization
is missing in mpz_addmul/mpz_submul. That is,

    mpz_addmul(sum, a, a);

is noticeably slower than

    mpz_mul(tmp, a, a);
    mpz_add(sum, sum, tmp);

This should be easy to fix.

Fredrik


More information about the gmp-devel mailing list