mpn_mul is embarrassingly slow

Marc Glisse marc.glisse at
Fri Apr 20 17:36:20 UTC 2018

On Fri, 20 Apr 2018, Marco Bodrato wrote:

> Il Ven, 20 Aprile 2018 12:39 pm, Marc Glisse ha scritto:
>> I just tried (LTO+PGO) on a trivial testcase, and gcc didn't manage to do
>> anything clever with it. Doing it by hand to see how much potential gain
>> there is, the timings are:
>> mpn_mul: .56
>> mpn_mul_n: .36
>> mpn_mul_basecase: .16
> Did you try also the documented function mpn_sec_mul?


> If you know in advance that the size of your operand are bounded by some
> given sizes, you can preallocate the required scratch space...

I'll admit that since I don't care about the security aspects, it didn't 
even occur to me to look at those functions for performance.

Marc Glisse

More information about the gmp-devel mailing list