From 121344ac338ef21d87eee4f64a60d0ae8a7f6fe3 Mon Sep 17 00:00:00 2001 From: ruinan Date: Wed, 13 Jul 2022 09:00:57 +0000 Subject: 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 Auto-Submit: Keith Randall Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Heschi Kreinick Run-TryBot: Keith Randall --- test/codegen/mathbits.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/codegen') 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 { -- cgit v1.3