cmd/compile: preload multi-instruction constants before loops on arm64
The register allocator never preloads rematerializeable values into
registers before a loop, so a 64-bit constant that needs MOVD plus up
to three MOVKs on arm64 is rebuilt on every iteration. Preload such
constants when a register is free, as is already done for other
values live into the loop.
Single-instruction constants are unchanged.
Neoverse N1, repro from the issue (HashVar loads the constant from a
variable and is unaffected):
│ base │ new │
│ sec/op │ sec/op vs base │
Hash 5.165µ ± 0% 4.128µ ± 0% -20.09% (p=0.000 n=10)
HashVar 4.128µ ± 0% 4.129µ ± 0% ~ (p=0.778 n=10)
For #81755
Change-Id: I87c5779b24057cd59833c2afc32c7ddef06a29df
Reviewed-on: https://go-review.googlesource.com/c/go/+/840405
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@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.