aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2020-04-20 14:43:30 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2020-04-21 00:38:34 +0000
commit50b11318febd74c26cc466cc4557347bcb53181a (patch)
tree1af35a1788920f922e481f23317091051988db56 /test
parent12665b9a067789004ca45cedcd3ebbbdc143f1d7 (diff)
downloadgo-50b11318febd74c26cc466cc4557347bcb53181a.tar.gz
go-50b11318febd74c26cc466cc4557347bcb53181a.zip
cmd/compile: use oneBit instead of isPowerOfTwo in bit optimization
This optimization works on any integer with exactly one bit set. This is identical to being a power of two, except in the most negative number. Use oneBit instead. The rule now triggers in a few more places in std+cmd, in packages encoding/asn1, crypto/elliptic, and vendor/golang.org/x/crypto/cryptobyte. This change obviates the need for CL 222479 by doing this optimization consistently in the compiler. Change-Id: I983c6235290fdc634fda5e11b10f1f8ce041272f Reviewed-on: https://go-review.googlesource.com/c/go/+/229124 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/codegen/bits.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/codegen/bits.go b/test/codegen/bits.go
index 18f9daf7cf..0a5428b55a 100644
--- a/test/codegen/bits.go
+++ b/test/codegen/bits.go
@@ -278,6 +278,11 @@ func bitOpOnMem(a []uint32) {
a[5] ^= 0x2000
}
+func bitcheckMostNegative(b uint8) bool {
+ // amd64:"TESTB"
+ return b&0x80 == 0x80
+}
+
// Check AND masking on arm64 (Issue #19857)
func and_mask_1(a uint64) uint64 {