aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorfanzha02 <fannie.zhang@arm.com>2021-03-23 15:35:30 +0800
committerfannie zhang <Fannie.Zhang@arm.com>2021-03-26 01:57:35 +0000
commit3a0061822e0bfa79f2a464807e12970f588e3e94 (patch)
treeb96494a288bbf787aea804c13a53216b09134d88 /test/codegen
parentb587b050ca55661120912b5a1d6071a1922ad0ea (diff)
downloadgo-3a0061822e0bfa79f2a464807e12970f588e3e94.tar.gz
go-3a0061822e0bfa79f2a464807e12970f588e3e94.zip
cmd/compile: add arm64 rules to optimize go codes to constant 0
Optimize the following codes to constant 0. function shift (x uint32) uint64 { return uint64(x) >> 32 } Change-Id: Ida6b39d713cc119ad5a2f01fd54bfd252cf2c975 Reviewed-on: https://go-review.googlesource.com/c/go/+/303830 Trust: fannie zhang <Fannie.Zhang@arm.com> Run-TryBot: fannie zhang <Fannie.Zhang@arm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/bitfield.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/codegen/bitfield.go b/test/codegen/bitfield.go
index 8acefbd027..0fe6799ec1 100644
--- a/test/codegen/bitfield.go
+++ b/test/codegen/bitfield.go
@@ -264,3 +264,14 @@ func rev16w(c uint32) (uint32, uint32, uint32) {
b3 := ((c & 0xff00ff00) >> 8) ^ ((c & 0x00ff00ff) << 8)
return b1, b2, b3
}
+
+func shift(x uint32, y uint16, z uint8) uint64 {
+ // arm64:-`MOVWU`,-`LSR\t[$]32`
+ a := uint64(x) >> 32
+ // arm64:-`MOVHU
+ b := uint64(y) >> 16
+ // arm64:-`MOVBU`
+ c := uint64(z) >> 8
+ // arm64:`MOVD\tZR`,-`ADD\tR[0-9]+>>16`,-`ADD\tR[0-9]+>>8`,
+ return a + b + c
+}