From 33a7e5a4b49fa04ce6f65b5b0645a44a0c93eaad Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 18 Aug 2022 14:13:33 -0700 Subject: cmd/compile: combine multiple rotate instructions Rotating by c, then by d, is the same as rotating by c+d. Change-Id: I36df82261460ff80f7c6d39bcdf0e840cef1c91a Reviewed-on: https://go-review.googlesource.com/c/go/+/424894 Reviewed-by: Wayne Zuo TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Reviewed-by: Ruinan Sun Run-TryBot: Keith Randall Reviewed-by: Heschi Kreinick --- test/codegen/rotate.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'test/codegen') diff --git a/test/codegen/rotate.go b/test/codegen/rotate.go index f42993532d..b22288f82a 100644 --- a/test/codegen/rotate.go +++ b/test/codegen/rotate.go @@ -204,6 +204,14 @@ func f32(x uint32) uint32 { return rot32nc(x, 7) } +func doubleRotate(x uint64) uint64 { + x = (x << 5) | (x >> 59) + // amd64:"ROLQ\t[$]15" + // arm64:"ROR\t[$]49" + x = (x << 10) | (x >> 54) + return x +} + // --------------------------------------- // // Combined Rotate + Masking operations // // --------------------------------------- // @@ -234,16 +242,16 @@ func checkMaskedRotate32(a []uint32, r int) { i++ // ppc64le: "RLWNM\tR[0-9]+, R[0-9]+, [$]16, [$]23, R[0-9]+" // ppc64: "RLWNM\tR[0-9]+, R[0-9]+, [$]16, [$]23, R[0-9]+" - a[i] = bits.RotateLeft32(a[3], r) & 0xFF00 + a[i] = bits.RotateLeft32(a[i], r) & 0xFF00 i++ // ppc64le: "RLWNM\tR[0-9]+, R[0-9]+, [$]20, [$]11, R[0-9]+" // ppc64: "RLWNM\tR[0-9]+, R[0-9]+, [$]20, [$]11, R[0-9]+" - a[i] = bits.RotateLeft32(a[3], r) & 0xFFF00FFF + a[i] = bits.RotateLeft32(a[i], r) & 0xFFF00FFF i++ // ppc64le: "RLWNM\t[$]4, R[0-9]+, [$]20, [$]11, R[0-9]+" // ppc64: "RLWNM\t[$]4, R[0-9]+, [$]20, [$]11, R[0-9]+" - a[i] = bits.RotateLeft32(a[3], 4) & 0xFFF00FFF + a[i] = bits.RotateLeft32(a[i], 4) & 0xFFF00FFF i++ } -- cgit v1.3