]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "cmd/compile: use cheaper implementation of oneBit"
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Apr 2020 04:28:23 +0000 (04:28 +0000)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Apr 2020 04:28:59 +0000 (04:28 +0000)
This reverts commit 066c47ca5fac1c49f754029f1e61323f74f6d93d.

Reason for revert: This appears to have broken a bunch of builders.

Change-Id: I68b4decf3c1892766e195d8eb018844cdff69443
Reviewed-on: https://go-review.googlesource.com/c/go/+/229177
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/ssa/rewrite.go

index 62580bceb8bc2fe0fc6b115d849ea91c4173aed6..d222b164fdd6a1a3300fd2653dd22a11f9bdc71c 100644 (file)
@@ -397,11 +397,11 @@ func ntz32(x int32) int { return bits.TrailingZeros32(uint32(x)) }
 func ntz16(x int16) int { return bits.TrailingZeros16(uint16(x)) }
 func ntz8(x int8) int   { return bits.TrailingZeros8(uint8(x)) }
 
-func oneBit(x int64) bool   { return x&(x-1) == 0 }
-func oneBit8(x int8) bool   { return x&(x-1) == 0 }
-func oneBit16(x int16) bool { return x&(x-1) == 0 }
-func oneBit32(x int32) bool { return x&(x-1) == 0 }
-func oneBit64(x int64) bool { return x&(x-1) == 0 }
+func oneBit(x int64) bool   { return bits.OnesCount64(uint64(x)) == 1 }
+func oneBit8(x int8) bool   { return bits.OnesCount8(uint8(x)) == 1 }
+func oneBit16(x int16) bool { return bits.OnesCount16(uint16(x)) == 1 }
+func oneBit32(x int32) bool { return bits.OnesCount32(uint32(x)) == 1 }
+func oneBit64(x int64) bool { return bits.OnesCount64(uint64(x)) == 1 }
 
 // nlo returns the number of leading ones.
 func nlo(x int64) int64 {