]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: ensure we keep top 32 bits zeroed for 32-bit arm64 ops
authorKeith Randall <khr@golang.org>
Fri, 18 Aug 2023 19:38:32 +0000 (12:38 -0700)
committerKeith Randall <khr@golang.org>
Mon, 21 Aug 2023 20:51:49 +0000 (20:51 +0000)
commita9bedc36a53f9d4ff6ab1c1a43c900c2fc8eba84
treee64143bd574adb16118e3490a16e5daa0584fdb9
parent1081f8c05807728738e1e6bf9097a41796fe5a05
cmd/compile: ensure we keep top 32 bits zeroed for 32-bit arm64 ops

When rewriting, for example, MSUBW, we need to ensure that the result
has its 32 top bits zeroed. That's what the instruction is spec'd to do.
Normally, we'd only use MSUBW for computations on 32-bit values, and
as such the top 32 bits aren't normally used. But some situations, like
if we cast the result to a uint64, the top 32 bits do matter.

This comes up in 62131 because we have a rule saying, MOVWUreg applied
to a MSUBW is unnecessary, as the arg to MOVWUreg already has zeroed
top 32 bits. But if MSUBW is later rewritten to another op that doesn't
zero the top 32 bits (SUB, probably), getting rid of the MOVWUreg earlier
causes a problem.

So change rewrite rules to always maintain the top 32 bits as zero if the
instruction is spec'd to provide that. We need to introduce a few *W operations
to make that happen.

Fixes #62131

Change-Id: If3d160821e285fd7454746b735a243671bff8894
Reviewed-on: https://go-review.googlesource.com/c/go/+/520916
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssa/_gen/ARM64.rules
src/cmd/compile/internal/ssa/rewriteARM64.go