]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use oneBit instead of isPowerOfTwo in bit optimization
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 20 Apr 2020 21:43:30 +0000 (14:43 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 21 Apr 2020 00:38:34 +0000 (00:38 +0000)
commit50b11318febd74c26cc466cc4557347bcb53181a
tree1af35a1788920f922e481f23317091051988db56
parent12665b9a067789004ca45cedcd3ebbbdc143f1d7
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>
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/compile/internal/ssa/rewritegeneric.go
test/codegen/bits.go