1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:52:17 -07:00

cmd/compile: Optimize ARM64's code with EON

This patch fuses pattern '(MVN (XOR x y))' into '(EON x y)'.

Change-Id: I269c98ce198d51a4945ce8bd0e1024acbd1b7609
Reviewed-on: https://go-review.googlesource.com/c/go/+/239638
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
diaxu01 2020-06-05 03:53:53 +00:00 committed by Cherry Zhang
parent 8d91d736e2
commit 01aad9ea93
3 changed files with 24 additions and 2 deletions

View File

@ -1323,6 +1323,7 @@
(AND x (MVN y)) -> (BIC x y) (AND x (MVN y)) -> (BIC x y)
(XOR x (MVN y)) -> (EON x y) (XOR x (MVN y)) -> (EON x y)
(OR x (MVN y)) -> (ORN x y) (OR x (MVN y)) -> (ORN x y)
(MVN (XOR x y)) -> (EON x y)
(CSEL {cc} x (MOVDconst [0]) flag) -> (CSEL0 {cc} x flag) (CSEL {cc} x (MOVDconst [0]) flag) -> (CSEL0 {cc} x flag)
(CSEL {cc} (MOVDconst [0]) y flag) -> (CSEL0 {arm64Negate(cc.(Op))} y flag) (CSEL {cc} (MOVDconst [0]) y flag) -> (CSEL0 {arm64Negate(cc.(Op))} y flag)
(SUB x (SUB y z)) -> (SUB (ADD <v.Type> x z) y) (SUB x (SUB y z)) -> (SUB (ADD <v.Type> x z) y)

View File

@ -14593,6 +14593,18 @@ func rewriteValueARM64_OpARM64MULW(v *Value) bool {
} }
func rewriteValueARM64_OpARM64MVN(v *Value) bool { func rewriteValueARM64_OpARM64MVN(v *Value) bool {
v_0 := v.Args[0] v_0 := v.Args[0]
// match: (MVN (XOR x y))
// result: (EON x y)
for {
if v_0.Op != OpARM64XOR {
break
}
y := v_0.Args[1]
x := v_0.Args[0]
v.reset(OpARM64EON)
v.AddArg2(x, y)
return true
}
// match: (MVN (MOVDconst [c])) // match: (MVN (MOVDconst [c]))
// result: (MOVDconst [^c]) // result: (MOVDconst [^c])
for { for {

View File

@ -310,9 +310,18 @@ func op_bic(x, y uint32) uint32 {
return x &^ y return x &^ y
} }
func op_eon(x, y uint32) uint32 { func op_eon(x, y, z uint32, a []uint32, n, m uint64) uint64 {
// arm64:`EON\t`,-`EOR`,-`MVN`
a[0] = x ^ (y ^ 0xffffffff)
// arm64:`EON\t`,-`EOR`,-`MVN`
a[1] = ^(y ^ z)
// arm64:`EON\t`,-`XOR` // arm64:`EON\t`,-`XOR`
return x ^ ^y a[2] = x ^ ^z
// arm64:`EON\t`,-`EOR`,-`MVN`
return n ^ (m ^ 0xffffffffffffffff)
} }
func op_orn(x, y uint32) uint32 { func op_orn(x, y uint32) uint32 {