Skip to content

Commit 1513661

Browse files
cuonglmgopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent bd94ae8 commit 1513661

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,10 @@ func nto(x int64) int64 {
480480

481481
// logX returns logarithm of n base 2.
482482
// n must be a positive power of 2 (isPowerOfTwoX returns true).
483-
func log8(n int8) int64 {
484-
return int64(bits.Len8(uint8(n))) - 1
485-
}
486-
func log16(n int16) int64 {
487-
return int64(bits.Len16(uint16(n))) - 1
488-
}
489-
func log32(n int32) int64 {
490-
return int64(bits.Len32(uint32(n))) - 1
491-
}
492-
func log64(n int64) int64 {
493-
return int64(bits.Len64(uint64(n))) - 1
494-
}
483+
func log8(n int8) int64 { return log8u(uint8(n)) }
484+
func log16(n int16) int64 { return log16u(uint16(n)) }
485+
func log32(n int32) int64 { return log32u(uint32(n)) }
486+
func log64(n int64) int64 { return log64u(uint64(n)) }
495487

496488
// logXu returns the logarithm of n base 2.
497489
// n must be a power of 2 (isUnsignedPowerOfTwo returns true)

0 commit comments

Comments
 (0)