]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj/arm64: shorten constant integer loads
authorKeith Randall <khr@golang.org>
Tue, 4 Nov 2025 23:15:16 +0000 (15:15 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 10 Nov 2025 17:34:13 +0000 (09:34 -0800)
commit3b3d6b9e5d9898810ee13e739f3ad759ab104fdb
tree167486b89c8c153d560836065874f4d54829169d
parent5f4b5f1a196774e45bc50de0729973119eb7bf07
cmd/internal/obj/arm64: shorten constant integer loads

Large integer constants can take up to 4 instructions to encode.

We can encode some large constants with a single instruction, namely
those which are bit patterns (repetitions of certain runs of 0s and 1s).

Often the constants we want to encode are *close* to those bit patterns,
but don't exactly match. For those, we can use 2 instructions, one to
load the close-by bit pattern and one to fix up any mismatches.

The constants we use to strength reduce divides often fit this pattern.
For unsigned divides by 1 through 15, this CL applies to the constant
for N=3,5,6,10,12,15.

Triggers 17 times in hello world.

Change-Id: I623abf32961fb3e74d0a163f6822f0647cd94499
Reviewed-on: https://go-review.googlesource.com/c/go/+/717900
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/arm64.s
src/cmd/internal/obj/arm64/asm7.go
src/cmd/internal/obj/arm64/asm_arm64_test.go
src/cmd/internal/obj/arm64/asm_arm64_test.s