]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.17] cmd/compile: ensure constant shift amounts are in range for arm
authorKeith Randall <khr@golang.org>
Mon, 20 Sep 2021 04:09:57 +0000 (21:09 -0700)
committerDmitri Shuralyov <dmitshur@golang.org>
Wed, 27 Oct 2021 21:13:34 +0000 (21:13 +0000)
commit3a03ddf735f0e8eff3f8325a496f28b71d3dbe39
tree4b2b41695c8f16beff379a6402913d226db1e4e7
parent644555d34e5154215e4599610d861ec598bfbef2
[release-branch.go1.17] 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 #48479

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>
(cherry picked from commit eff27e858b771bf5e0b5e7e836827c7d2941e6d4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/351069
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/ssa/gen/ARM.rules
src/cmd/compile/internal/ssa/gen/ARMOps.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/rewriteARM.go
test/fixedbugs/issue48476.go [new file with mode: 0644]