aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/gen/genericOps.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-09-19 21:09:57 -0700
committerKeith Randall <khr@golang.org>2021-09-20 16:26:30 +0000
commiteff27e858b771bf5e0b5e7e836827c7d2941e6d4 (patch)
treeca1468999c555287ae4bca5705c260e06b7176cf /src/cmd/compile/internal/ssa/gen/genericOps.go
parent9ebe7c8ec6e95b73a7b0e480fe10f2188ef4928a (diff)
downloadgo-eff27e858b771bf5e0b5e7e836827c7d2941e6d4.tar.gz
go-eff27e858b771bf5e0b5e7e836827c7d2941e6d4.zip
cmd/compile: ensure constant shift amounts are in range for arm
Ensure constant shift amounts are in the range [0-31]. When shift amounts are out of range, bad things happen. Shift amounts out of range occur when lowering 64-bit shifts (we take an in-range shift s in [0-63] and calculate s-32 and 32-s, both of which might be out of [0-31]). The constant shift operations themselves still work, but their shift amounts get copied unmolested to operations like ORshiftLL which use only the low 5 bits. That changes an operation like <<100 which unconditionally produces 0, to <<4, which doesn't. Fixes #48476 Change-Id: I87363ef2b4ceaf3b2e316426064626efdfbb8ee3 Reviewed-on: https://go-review.googlesource.com/c/go/+/350969 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/gen/genericOps.go')
-rw-r--r--src/cmd/compile/internal/ssa/gen/genericOps.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/gen/genericOps.go b/src/cmd/compile/internal/ssa/gen/genericOps.go
index a0166f58f4..984552900f 100644
--- a/src/cmd/compile/internal/ssa/gen/genericOps.go
+++ b/src/cmd/compile/internal/ssa/gen/genericOps.go
@@ -106,7 +106,7 @@ var genericOps = []opData{
// For shifts, AxB means the shifted value has A bits and the shift amount has B bits.
// Shift amounts are considered unsigned.
- // If arg1 is known to be less than the number of bits in arg0,
+ // If arg1 is known to be nonnegative and less than the number of bits in arg0,
// then auxInt may be set to 1.
// This enables better code generation on some platforms.
{name: "Lsh8x8", argLength: 2, aux: "Bool"}, // arg0 << arg1