From 1513661dc3b917ffe99e658919b4adc4f08853aa Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 29 Jul 2025 23:39:08 +0700 Subject: [PATCH] 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 Reviewed-by: Keith Randall Reviewed-by: David Chase Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/ssa/rewrite.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 0a1a680bab..6229992bd1 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -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) -- 2.51.0