cmd/compile/internal/ssa: elide redundant 32-bit zero extensions on arm64 - #80566
cmd/compile/internal/ssa: elide redundant 32-bit zero extensions on arm64#80566andig wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This comment was marked as resolved.
This comment was marked as resolved.
|
This PR (HEAD: cff9a65) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/805860. Important tips:
|
…rm64 ZeroUpper32Bits knows about arm64's W-form ALU results, but not about its zero-extending loads and register moves. The late lower rule (MOVWUreg x) && ZeroUpper32Bits(x, 3) => x therefore never fires for a value that came from MOVWUload/MOVHUload/MOVBUload or from a narrower MOV*Ureg. When such a value has a single use the extension still folds away, via (MOVWUreg x:(MOVWUload _ _)) => (MOVDreg x) and (MOVDreg x) && x.Uses == 1 => (MOVDnop x). With a second consumer -- a loaded uint32 field used both as a slice index and in a bounds compare, the regexp onepass shape -- the MOVDreg survives as a real MOVD Rx,Ry register copy. Add the arm64 zero-extending loads and register moves to ZeroUpper32Bits, mirroring the byte and halfword op lists that CL 804064 adds to ZeroUpper56Bits and ZeroUpper48Bits. This removes 117 register copies in std at GOARCH=arm64 (runtime -36, regexp -26, internal/zstd -11, internal/coverage/cformat -8) for -592 bytes of function text, with a single-copy regression in errors. Updates golang#43357
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
This PR (HEAD: afe5236) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/805860. Important tips:
|
|
Message from Andreas Goetz: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from Jorropo: Patch Set 2: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-07-26T03:02:19Z","revision":"47e9cdce905d93f8c6a6a8a499c9a9587d9dd334"} Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from Jorropo: Patch Set 2: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_55763>) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 2: This CL has failed the run. Reason: Tryjob golang/try/gotip-windows-386 has failed with summary (view all results):
To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 2: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from Andreas Goetz: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
|
Message from Keith Randall: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/805860. |
ZeroUpper32Bits knows about arm64's W-form ALU results, but not about its
zero-extending loads and register moves. The late lower rule
(MOVWUreg x) && ZeroUpper32Bits(x, 3) => x therefore never fires for a
value that came from MOVWUload/MOVHUload/MOVBUload or from a narrower
MOV*Ureg.
With a single use the extension still folds away, via
(MOVWUreg x:(MOVWUload _ _)) => (MOVDreg x) and
(MOVDreg x) && x.Uses == 1 => (MOVDnop x). With a second consumer -- a
loaded uint32 field used both as a slice index and in a bounds compare,
the regexp onepass shape -- the MOVDreg survives as a real MOVD Rx,Ry
register copy.
Add the arm64 zero-extending loads and register moves to
ZeroUpper32Bits, mirroring the byte and halfword op lists that CL 804064
adds to ZeroUpper56Bits and ZeroUpper48Bits. The two changes are
independent; this one applies on its own.
Measured at 7b4aab8 with go build -a -gcflags=-S std at
GOARCH=arm64: 117 fewer register copies (runtime -36, regexp -26,
internal/zstd -11, internal/coverage/cformat -8) for -592 bytes of
function text across 26 packages, with a single-copy regression in
errors.
Updates #43357