diff options
| author | wdvxdr <wdvxdr1123@gmail.com> | 2021-09-30 09:57:04 +0800 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2021-10-05 16:06:49 +0000 |
| commit | 060cd73ab930339d4565b57593293615b0e0315a (patch) | |
| tree | 9c6574e0a10024520b0188e85cd1917024ff14f5 /test/codegen/mathbits.go | |
| parent | f1f626de5382220f3b34fd3f5616d5c0868b3561 (diff) | |
| download | go-060cd73ab930339d4565b57593293615b0e0315a.tar.xz | |
cmd/compile: use TZCNT instruction for GOAMD64>=v3
on my Intel CoffeeLake CPU:
name old time/op new time/op delta
TrailingZeros-8 0.68ns ± 1% 0.64ns ± 1% -6.26% (p=0.000 n=10+10)
TrailingZeros8-8 0.70ns ± 1% 0.70ns ± 1% ~ (p=0.697 n=10+10)
TrailingZeros16-8 0.70ns ± 1% 0.70ns ± 1% +0.57% (p=0.043 n=10+10)
TrailingZeros32-8 0.66ns ± 1% 0.64ns ± 1% -3.35% (p=0.000 n=10+10)
TrailingZeros64-8 0.68ns ± 1% 0.64ns ± 1% -5.84% (p=0.000 n=9+10)
Updates #45453
Change-Id: I228ff2d51df24b1306136f061432f8a12bb1d6fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/353249
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/mathbits.go')
| -rw-r--r-- | test/codegen/mathbits.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index aecd84a78b..50527fea04 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -272,7 +272,8 @@ func RotateLeftVariable32(n uint32, m int) uint32 { // ------------------------ // func TrailingZeros(n uint) int { - // amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ" + // amd64/v1,amd64/v2:"BSFQ","MOVL\t\\$64","CMOVQEQ" + // amd64/v3:"TZCNTQ" // arm:"CLZ" // arm64:"RBIT","CLZ" // s390x:"FLOGR" @@ -285,7 +286,8 @@ func TrailingZeros(n uint) int { } func TrailingZeros64(n uint64) int { - // amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ" + // amd64/v1,amd64/v2:"BSFQ","MOVL\t\\$64","CMOVQEQ" + // amd64/v3:"TZCNTQ" // arm64:"RBIT","CLZ" // s390x:"FLOGR" // ppc64/power8:"ANDN","POPCNTD" @@ -303,7 +305,8 @@ func TrailingZeros64Subtract(n uint64) int { } func TrailingZeros32(n uint32) int { - // amd64:"BTSQ\\t\\$32","BSFQ" + // amd64/v1,amd64/v2:"BTSQ\\t\\$32","BSFQ" + // amd64/v3:"TZCNTL" // arm:"CLZ" // arm64:"RBITW","CLZW" // s390x:"FLOGR","MOVWZ" @@ -343,7 +346,8 @@ func TrailingZeros8(n uint8) int { func IterateBits(n uint) int { i := 0 for n != 0 { - // amd64:"BSFQ",-"CMOVEQ" + // amd64/v1,amd64/v2:"BSFQ",-"CMOVEQ" + // amd64/v3:"TZCNTQ" i += bits.TrailingZeros(n) n &= n - 1 } @@ -353,7 +357,8 @@ func IterateBits(n uint) int { func IterateBits64(n uint64) int { i := 0 for n != 0 { - // amd64:"BSFQ",-"CMOVEQ" + // amd64/v1,amd64/v2:"BSFQ",-"CMOVEQ" + // amd64/v3:"TZCNTQ" i += bits.TrailingZeros64(n) n &= n - 1 } @@ -363,7 +368,8 @@ func IterateBits64(n uint64) int { func IterateBits32(n uint32) int { i := 0 for n != 0 { - // amd64:"BSFL",-"BTSQ" + // amd64/v1,amd64/v2:"BSFL",-"BTSQ" + // amd64/v3:"TZCNTL" i += bits.TrailingZeros32(n) n &= n - 1 } @@ -373,7 +379,8 @@ func IterateBits32(n uint32) int { func IterateBits16(n uint16) int { i := 0 for n != 0 { - // amd64:"BSFL",-"BTSL" + // amd64/v1,amd64/v2:"BSFL",-"BTSL" + // amd64/v3:"TZCNTL" // arm64:"RBITW","CLZW",-"ORR" i += bits.TrailingZeros16(n) n &= n - 1 @@ -384,7 +391,8 @@ func IterateBits16(n uint16) int { func IterateBits8(n uint8) int { i := 0 for n != 0 { - // amd64:"BSFL",-"BTSL" + // amd64/v1,amd64/v2:"BSFL",-"BTSL" + // amd64/v3:"TZCNTL" // arm64:"RBITW","CLZW",-"ORR" i += bits.TrailingZeros8(n) n &= n - 1 |
