Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math/big: better multiply primitives #9245

griesemer opened this issue Dec 10, 2014 · 3 comments

math/big: better multiply primitives #9245

griesemer opened this issue Dec 10, 2014 · 3 comments


Copy link

@griesemer griesemer commented Dec 10, 2014

Suggestions from Torbjörn Granlund (personal e-mail):

The multiply primitives, in particular addMulVVW surely deserves more

Offset the pointers so that you can index with a counter register
which goes from -n to 0, saving the CMPQ.

Unroll. You can save most of the ADCQ $0, R that way. Basically,
do one run with just MULQ where you sum the old highpart (DX) with
the new lowpart (AX). You will need some MOVQ to move DX
out-of-the-way too. Then do a new run over these sums where you
bring in the memory addend. This should double the speed on some
newer CPUs.

A good addMulVVW is probably really the first thing to write in
assembly; addition and subtraction is much less important, usually.

@griesemer griesemer self-assigned this Dec 10, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@griesemer griesemer modified the milestones: Go1.9Maybe, Unplanned Feb 25, 2017
@griesemer griesemer modified the milestones: Go1.10, Go1.9Maybe May 9, 2017
@griesemer griesemer modified the milestones: Go1.10, Go1.11 Nov 3, 2017
Copy link

@vielmetti vielmetti commented Nov 9, 2017

See also (for arm64) where it is reported:

The lack of proper addMulVVW implementation for arm64 hurts RSA

This is an optimized implementation, it improves RSA2048 performance
by 10X to 15X on ARMv8 based server processors.

Copy link

@odeke-em odeke-em commented Mar 5, 2018

Copy link
Contributor Author

@griesemer griesemer commented May 24, 2018

Pushing to next release. There are some discussions about other math/bits primitive operations; maybe we can write some of this code in Go rather than assembly at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants