aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/mathbits.go
diff options
context:
space:
mode:
authorruinan <ruinan.sun@arm.com>2022-07-13 09:00:57 +0000
committerGopher Robot <gobot@golang.org>2022-09-02 17:46:31 +0000
commit121344ac338ef21d87eee4f64a60d0ae8a7f6fe3 (patch)
treea01377bbbb4aa9f6c8401eee8277412d8062d249 /test/codegen/mathbits.go
parentf45c2d7e47e6dcfb69876092037257562813cc37 (diff)
downloadgo-121344ac338ef21d87eee4f64a60d0ae8a7f6fe3.tar.xz
cmd/compile: optimize RotateLeft8/16 on arm64
This CL optimizes RotateLeft8/16 on arm64. For 16 bits, we form a 32 bits register by duplicating two 16 bits registers, then use RORW instruction to do the rotate shift. For 8 bits, we just use LSR and LSL instead of RORW because the code is simpler. Benchmark Old ThisCL delta RotateLeft8-46 2.16 ns/op 1.73 ns/op -19.70% RotateLeft16-46 2.16 ns/op 1.54 ns/op -28.53% Change-Id: I09cde4383d12e31876a57f8cdfd3bb4f324fadb0 Reviewed-on: https://go-review.googlesource.com/c/go/+/420976 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/mathbits.go')
-rw-r--r--test/codegen/mathbits.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go
index 9c643647ee..0620766f5a 100644
--- a/test/codegen/mathbits.go
+++ b/test/codegen/mathbits.go
@@ -258,14 +258,16 @@ func RotateLeft32(n uint32) uint32 {
return bits.RotateLeft32(n, 9)
}
-func RotateLeft16(n uint16) uint16 {
+func RotateLeft16(n uint16, s int) uint16 {
// amd64:"ROLW" 386:"ROLW"
- return bits.RotateLeft16(n, 5)
+ // arm64:"RORW",-"CSEL"
+ return bits.RotateLeft16(n, s)
}
-func RotateLeft8(n uint8) uint8 {
+func RotateLeft8(n uint8, s int) uint8 {
// amd64:"ROLB" 386:"ROLB"
- return bits.RotateLeft8(n, 5)
+ // arm64:"LSL","LSR",-"CSEL"
+ return bits.RotateLeft8(n, s)
}
func RotateLeftVariable(n uint, m int) uint {