diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2025-08-04 18:59:17 +0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-08-05 08:34:05 -0700 |
| commit | 72147ffa7556b2cd694a58ab562cb7e5b5c0514e (patch) | |
| tree | 2ddd4d50e684cd49a8b5acac6c80cad05711a71c /src | |
| parent | 26da1199ebdddeebc5eebdd562d8a40f01f42a1b (diff) | |
| download | go-72147ffa7556b2cd694a58ab562cb7e5b5c0514e.tar.xz | |
cmd/compile: simplify isUintXPowerOfTwo implementation
By calling isUnsignedPowerOfTwo instead of duplicating the same ones.
Change-Id: I1e29d3b7eda1bc8773fcd25728d8f508ae633ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/692916
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/ssa/rewrite.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 5edcc86a42..0d000370d5 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -505,16 +505,10 @@ func isUnsignedPowerOfTwo[T uint8 | uint16 | uint32 | uint64](n T) bool { } // isUint64PowerOfTwo reports whether uint64(n) is a power of 2. -func isUint64PowerOfTwo(in int64) bool { - n := uint64(in) - return n != 0 && n&(n-1) == 0 -} +func isUint64PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint64(in)) } // isUint32PowerOfTwo reports whether uint32(n) is a power of 2. -func isUint32PowerOfTwo(in int64) bool { - n := uint64(uint32(in)) - return n != 0 && n&(n-1) == 0 -} +func isUint32PowerOfTwo(in int64) bool { return isUnsignedPowerOfTwo(uint32(in)) } // is32Bit reports whether n can be represented as a signed 32 bit integer. func is32Bit(n int64) bool { |
