]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify logX implementations
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 29 Jul 2025 16:39:08 +0000 (23:39 +0700)
committerGopher Robot <gobot@golang.org>
Tue, 29 Jul 2025 23:22:45 +0000 (16:22 -0700)
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>

src/cmd/compile/internal/ssa/rewrite.go

index 0a1a680bab7d09adc8e1f286878f2ddbb0732618..6229992bd1ff6df2a20420bff33a556479052437 100644 (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)