aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2025-07-23 23:51:16 +0700
committerGopher Robot <gobot@golang.org>2025-07-29 16:22:40 -0700
commitbd94ae8903e6256d9777a28bf86f425116fca316 (patch)
tree34a2a16be13141b3ab5eee715300d925e6e16380 /test/codegen
parentf3582fc80e19050d915ac9621bbeecef78c0548e (diff)
downloadgo-bd94ae8903e6256d9777a28bf86f425116fca316.tar.xz
cmd/compile: use unsigned power-of-two detector for unsigned mod
Same as CL 689815, but for modulus instead of division. Updates #74485 Change-Id: I73000231c886a987a1093669ff207fd9117a8160 Reviewed-on: https://go-review.googlesource.com/c/go/+/689895 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/issue74485.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/codegen/issue74485.go b/test/codegen/issue74485.go
index 570707509b..b5aba9568c 100644
--- a/test/codegen/issue74485.go
+++ b/test/codegen/issue74485.go
@@ -25,3 +25,23 @@ func divUint8(b uint8) uint8 {
// amd64:"SHRB [$]7, AL"
return b / 128
}
+
+func modUint64(b uint64) uint64 {
+ // amd64:"BTRQ [$]63, AX"
+ return b % 9223372036854775808
+}
+
+func modUint32(b uint32) uint32 {
+ // amd64:"ANDL [$]2147483647, AX"
+ return b % 2147483648
+}
+
+func modUint16(b uint16) uint16 {
+ // amd64:"ANDL [$]32767, AX"
+ return b % 32768
+}
+
+func modUint8(b uint8) uint8 {
+ // amd64:"ANDL [$]127, AX"
+ return b % 128
+}