0
1
mirror of https://github.com/golang/go synced 2025-09-18 07:39:28 +00:00
Files
go/test/codegen/issue74485.go
Cuong Manh Le bd94ae8903 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>
2025-07-29 16:22:40 -07:00

48 lines
884 B
Go

// asmcheck
// Copyright 2025 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 codegen
func divUint64(b uint64) uint64 {
// amd64:"SHRQ [$]63, AX"
return b / 9223372036854775808
}
func divUint32(b uint32) uint32 {
// amd64:"SHRL [$]31, AX"
return b / 2147483648
}
func divUint16(b uint16) uint16 {
// amd64:"SHRW [$]15, AX"
return b / 32768
}
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
}