crypto/internal/fips140/aes: avoid stack round-trip when building counter blocks on loong64
ctrBlocks1/2/4/8Asm previously built each 128-bit counter block by
storing the two big-endian 64-bit halves to a stack scratch buffer
and then reloading them with VMOVQ. Replace this with VMOVQ Rj,
Vd.V[index] (vinsgr2vr.d), which writes each half directly into the
target vector register lane, eliminating the store-to-load round
trip. This also lets the stack frame for these four functions shrink
from $16/$32 to $0.
goos: linux
goarch: loong64
pkg: crypto/cipher
cpu: Loongson-3C6000/S @ 2200.00MHz
| old.bench.aesctr | new.bench.aesctr |
| sec/op | sec/op vs base |
AESCTR/128/50 363.9n ± 0% 327.1n ± 0% -10.11% (p=0.000 n=10)
AESCTR/128/1K 4.310µ ± 0% 3.963µ ± 0% -8.05% (p=0.000 n=10)
AESCTR/128/8K 33.25µ ± 0% 30.57µ ± 0% -8.06% (p=0.000 n=10)
AESCTR/192/50 424.8n ± 0% 388.7n ± 0% -8.50% (p=0.000 n=10)
AESCTR/192/1K 5.090µ ± 0% 4.742µ ± 0% -6.84% (p=0.000 n=10)
AESCTR/192/8K 39.30µ ± 0% 36.60µ ± 0% -6.87% (p=0.000 n=10)
AESCTR/256/50 485.4n ± 0% 450.0n ± 0% -7.29% (p=0.000 n=10)
AESCTR/256/1K 5.861µ ± 0% 5.516µ ± 0% -5.89% (p=0.000 n=10)
AESCTR/256/8K 45.28µ ± 0% 42.60µ ± 0% -5.92% (p=0.000 n=10)
geomean 4.361µ 4.034µ -7.51%
goos: linux
goarch: loong64
pkg: crypto/cipher
cpu: Loongson-3A5000 @ 2500.00MHz
| old.bench.aesctr | new.bench.aesctr |
| sec/op | sec/op vs base |
AESCTR/128/50 407.7n ± 0% 387.1n ± 0% -5.05% (p=0.000 n=10)
AESCTR/128/1K 5.232µ ± 0% 4.925µ ± 0% -5.87% (p=0.000 n=10)
AESCTR/128/8K 40.58µ ± 0% 38.14µ ± 0% -6.03% (p=0.000 n=10)
AESCTR/192/50 477.8n ± 0% 453.7n ± 0% -5.04% (p=0.000 n=10)
AESCTR/192/1K 6.201µ ± 0% 5.890µ ± 0% -5.02% (p=0.000 n=10)
AESCTR/192/8K 48.15µ ± 0% 45.67µ ± 0% -5.14% (p=0.000 n=10)
AESCTR/256/50 543.5n ± 0% 522.5n ± 0% -3.86% (p=0.000 n=10)
AESCTR/256/1K 7.161µ ± 0% 6.852µ ± 0% -4.32% (p=0.000 n=10)
AESCTR/256/8K 55.62µ ± 1% 53.19µ ± 0% -4.38% (p=0.000 n=10)
geomean 5.177µ 4.920µ -4.97%
Change-Id: I6fc973db36454b2e94272b09a0ee93e3842fe950
Reviewed-on: https://go-review.googlesource.com/c/go/+/835565
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.