From 8ab42a945aef7c09189a60263c4450a65bc00a47 Mon Sep 17 00:00:00 2001 From: fanzha02 Date: Tue, 3 Nov 2020 17:31:04 +0800 Subject: cmd/compile: merge ANDconst and UBFX into UBFX on arm64 Add a new rewrite rule to merge ANDconst and UBFX into UBFX. Add test cases. Change-Id: I24d6442d0c956d7ce092c3a3858d4a3a41771670 Reviewed-on: https://go-review.googlesource.com/c/go/+/377054 Trust: Fannie Zhang Reviewed-by: Cherry Mui Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- test/codegen/bitfield.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/bitfield.go b/test/codegen/bitfield.go index 8327da6cf8..11f31ecf25 100644 --- a/test/codegen/bitfield.go +++ b/test/codegen/bitfield.go @@ -321,6 +321,12 @@ func ubfx15(x uint64) bool { return false } +// merge ANDconst and ubfx into ubfx +func ubfx16(x uint64) uint64 { + // arm64:"UBFX\t[$]4, R[0-9]+, [$]6",-"AND\t[$]63" + return ((x >> 3) & 0xfff) >> 1 & 0x3f +} + // Check that we don't emit comparisons for constant shifts. //go:nosplit func shift_no_cmp(x int) int { -- cgit v1.3