aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-05-07 14:14:39 -0700
committerBen Shi <powerman1st@163.com>2021-05-08 03:27:59 +0000
commitb211fe005860db3ceff5fd56af9951d6d1f44325 (patch)
tree2d4db9f01381ed1cab1ac47f620d08865e6a78ef /test
parentf24eac47710b0170fd45611ab1867e87701e0a95 (diff)
downloadgo-b211fe005860db3ceff5fd56af9951d6d1f44325.tar.gz
go-b211fe005860db3ceff5fd56af9951d6d1f44325.zip
cmd/compile: remove bit operations that modify memory directly
These operations (BT{S,R,C}{Q,L}modify) are quite a bit slower than other ways of doing the same thing. Without the BTxmodify operations, there are two fallback ways the compiler performs these operations: AND/OR/XOR operations directly on memory, or load-BTx-write sequences. The compiler kinda chooses one arbitrarily depending on rewrite rule application order. Currently, it uses load-BTx-write for the Const benchmarks and AND/OR/XOR directly to memory for the non-Const benchmarks. TBD, someone might investigate which of the two fallback strategies is really better. For now, they are both better than BTx ops. name old time/op new time/op delta BitSet-8 1.09µs ± 2% 0.64µs ± 5% -41.60% (p=0.000 n=9+10) BitClear-8 1.15µs ± 3% 0.68µs ± 6% -41.00% (p=0.000 n=10+10) BitToggle-8 1.18µs ± 4% 0.73µs ± 2% -38.36% (p=0.000 n=10+8) BitSetConst-8 37.0ns ± 7% 25.8ns ± 2% -30.24% (p=0.000 n=10+10) BitClearConst-8 30.7ns ± 2% 25.0ns ±12% -18.46% (p=0.000 n=10+10) BitToggleConst-8 36.9ns ± 1% 23.8ns ± 3% -35.46% (p=0.000 n=9+10) Fixes #45790 Update #45242 Change-Id: Ie33a72dc139f261af82db15d446cd0855afb4e59 Reviewed-on: https://go-review.googlesource.com/c/go/+/318149 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ben Shi <powerman1st@163.com>
Diffstat (limited to 'test')
-rw-r--r--test/codegen/bits.go12
1 files changed, 0 insertions, 12 deletions
diff --git a/test/codegen/bits.go b/test/codegen/bits.go
index 2bd92dd51b..8117a62307 100644
--- a/test/codegen/bits.go
+++ b/test/codegen/bits.go
@@ -270,18 +270,6 @@ func bitOpOnMem(a []uint32, b, c, d uint32) {
a[1] |= 220
// amd64:`XORL\s[$]240,\s8\([A-Z][A-Z0-9]+\)`
a[2] ^= 240
- // amd64:`BTRL\s[$]15,\s12\([A-Z][A-Z0-9]+\)`,-`ANDL`
- a[3] &= 0xffff7fff
- // amd64:`BTSL\s[$]14,\s16\([A-Z][A-Z0-9]+\)`,-`ORL`
- a[4] |= 0x4000
- // amd64:`BTCL\s[$]13,\s20\([A-Z][A-Z0-9]+\)`,-`XORL`
- a[5] ^= 0x2000
- // amd64:`BTRL\s[A-Z][A-Z0-9]+,\s24\([A-Z][A-Z0-9]+\)`
- a[6] &^= 1 << (b & 31)
- // amd64:`BTSL\s[A-Z][A-Z0-9]+,\s28\([A-Z][A-Z0-9]+\)`
- a[7] |= 1 << (c & 31)
- // amd64:`BTCL\s[A-Z][A-Z0-9]+,\s32\([A-Z][A-Z0-9]+\)`
- a[8] ^= 1 << (d & 31)
}
func bitcheckMostNegative(b uint8) bool {