aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-12-14 13:07:50 -0800
committerKeith Randall <khr@golang.org>2023-12-15 19:35:21 +0000
commitb60bf8f8e131b026eb2691e736d3df9dce852297 (patch)
tree4ddaf9a9843712e08e4aa78fee48bf72c957552b /test
parent5e939b3a9ce7864551e86c04a05db887c25e2759 (diff)
downloadgo-b60bf8f8e131b026eb2691e736d3df9dce852297.tar.gz
go-b60bf8f8e131b026eb2691e736d3df9dce852297.zip
cmd/asm: fix encoding for arm right shift by constant 0
Right shifts, for some odd reasons, can encode shifts of constant 1-32 instead of 0-31. Left shifts, however, can encode shifts 0-31. When the shift amount is 0, arm recommends encoding right shifts using left shifts. Fixes #64715 Change-Id: Id3825349aa7195028037893dfe01fa0e405eaa51 Reviewed-on: https://go-review.googlesource.com/c/go/+/549955 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/fixedbugs/issue64715.go25
-rw-r--r--test/fixedbugs/issue64715.out1
2 files changed, 26 insertions, 0 deletions
diff --git a/test/fixedbugs/issue64715.go b/test/fixedbugs/issue64715.go
new file mode 100644
index 0000000000..bf117165b7
--- /dev/null
+++ b/test/fixedbugs/issue64715.go
@@ -0,0 +1,25 @@
+// run
+
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func boolInt32(b bool) int32 {
+ if b {
+ return 1
+ }
+
+ return 0
+}
+
+func f(left uint16, right int32) (r uint16) {
+ return left >> right
+}
+
+var n = uint16(65535)
+
+func main() {
+ println(f(n, boolInt32(int64(n^n) > 1)))
+}
diff --git a/test/fixedbugs/issue64715.out b/test/fixedbugs/issue64715.out
new file mode 100644
index 0000000000..7a53b35687
--- /dev/null
+++ b/test/fixedbugs/issue64715.out
@@ -0,0 +1 @@
+65535