mirror of
https://github.com/golang/go.git
synced 2026-07-30 21:34:12 +08:00
Add a MULXQ SSA op (BMI2 unsigned 64x64->128 multiply) and switch
the AMD64 lowering of Mul64uhilo to emit MULXQ when GOAMD64>=v3.
Unlike MULQ, MULXQ takes its first operand implicitly in RDX, places
both halves of the product in any general-purpose registers, and
does not affect the flags. The latter makes it interleavable with
ADCX/ADOX carry chains, which is the prerequisite for the
dual-carry-chain Montgomery multiplication.
The downside is that MULXQ ends up encoding as 5-6 bytes instead
of 3 bytes. However for bits.Mul64 it tends to balance out due
to needing less register shuffling.
On its own the change is modest but measurable on the fiat-based
P-384/P-521 paths in crypto/ecdsa, where bits.Mul64 dominates:
goos: linux
goarch: amd64
pkg: crypto/ecdsa
cpu: AMD Ryzen Threadripper 2950X 16-Core Processor
│ old │ new │
│ sec/op │ sec/op vs base │
Sign/P256-32 53.39µ ± 4% 53.23µ ± 5% ~ (p=1.000 n=6)
Sign/P384-32 284.3µ ± 3% 284.2µ ± 3% ~ (p=0.699 n=6)
Sign/P521-32 650.1µ ± 2% 663.1µ ± 2% +1.99% (p=0.015 n=6)
Verify/P256-32 76.27µ ± 2% 75.07µ ± 4% -1.57% (p=0.041 n=6)
Verify/P384-32 840.5µ ± 1% 793.1µ ± 2% -5.64% (p=0.002 n=6)
Verify/P521-32 2.147m ± 1% 2.091m ± 1% -2.65% (p=0.002 n=6)
GenerateKey/P256-32 16.79µ ± 3% 16.63µ ± 5% ~ (p=0.589 n=6)
GenerateKey/P384-32 183.1µ ± 3% 171.8µ ± 2% -6.20% (p=0.002 n=6)
GenerateKey/P521-32 445.7µ ± 2% 432.4µ ± 0% -2.98% (p=0.002 n=6)
geomean 230.8µ 226.1µ -2.07%
Change-Id: I40a9753ccc511bf6f55d3ca428a439807906c292
Reviewed-on: https://go-review.googlesource.com/c/go/+/781841
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
The test directory contains tests of the Go tool chain and runtime. It includes black box tests, regression tests, and error output tests. They are run as part of all.bash.
To run just these tests, execute:
../bin/go test cmd/internal/testdir
To run just tests from specified files in this directory, execute:
../bin/go test cmd/internal/testdir -run='Test/(file1.go|file2.go|...)'
Standard library tests should be written as regular Go tests in the appropriate package.
The tool chain and runtime also have regular Go tests in their packages. The main reasons to add a new test to this directory are:
- it is most naturally expressed using the test runner; or
- it is also applicable to
gccgoand other Go tool chains.