cmd/compile: simplify logX implementations

By calling logXu instead of duplicating the same ones.

Change-Id: Ide7a3ce072a6abafe1979f0158000457d90645c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/691475
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cuong Manh Le 2025-07-29 23:39:08 +07:00 committed by Gopher Robot
parent bd94ae8903
commit 1513661dc3

View file

@ -480,18 +480,10 @@ func nto(x int64) int64 {
// logX returns logarithm of n base 2.
// n must be a positive power of 2 (isPowerOfTwoX returns true).
func log8(n int8) int64 {
return int64(bits.Len8(uint8(n))) - 1
}
func log16(n int16) int64 {
return int64(bits.Len16(uint16(n))) - 1
}
func log32(n int32) int64 {
return int64(bits.Len32(uint32(n))) - 1
}
func log64(n int64) int64 {
return int64(bits.Len64(uint64(n))) - 1
}
func log8(n int8) int64 { return log8u(uint8(n)) }
func log16(n int16) int64 { return log16u(uint16(n)) }
func log32(n int32) int64 { return log32u(uint32(n)) }
func log64(n int64) int64 { return log64u(uint64(n)) }
// logXu returns the logarithm of n base 2.
// n must be a power of 2 (isUnsignedPowerOfTwo returns true)