1
0
mirror of https://github.com/golang/go synced 2024-11-18 05:54:49 -07:00

cmd/compile: add rule to use ANDN for a&^b on ppc64x

Adds a rule to generate ANDN for AND x ^y.

Fixes #17567

Change-Id: I3b978058d5663f32c42b1af19bb207eac5622615
Reviewed-on: https://go-review.googlesource.com/31769
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Lynn Boger 2016-10-24 14:19:18 -05:00 committed by David Chase
parent 7124056f7e
commit 95f3e47456
2 changed files with 21 additions and 0 deletions

View File

@ -267,6 +267,9 @@
(OrB x y) -> (OR x y) (OrB x y) -> (OR x y)
(Not x) -> (XORconst [1] x) (Not x) -> (XORconst [1] x)
// Use ANDN for AND x NOT y
(AND x (XORconst [-1] y)) -> (ANDN x y)
// Lowering comparisons // Lowering comparisons
(EqB x y) -> (ANDconst [1] (EQV x y)) (EqB x y) -> (ANDconst [1] (EQV x y))
// Sign extension dependence on operand sign sets up for sign/zero-extension elision later // Sign extension dependence on operand sign sets up for sign/zero-extension elision later

View File

@ -4471,6 +4471,24 @@ func rewriteValuePPC64_OpPPC64ADDconst(v *Value, config *Config) bool {
func rewriteValuePPC64_OpPPC64AND(v *Value, config *Config) bool { func rewriteValuePPC64_OpPPC64AND(v *Value, config *Config) bool {
b := v.Block b := v.Block
_ = b _ = b
// match: (AND x (XORconst [-1] y))
// cond:
// result: (ANDN x y)
for {
x := v.Args[0]
v_1 := v.Args[1]
if v_1.Op != OpPPC64XORconst {
break
}
if v_1.AuxInt != -1 {
break
}
y := v_1.Args[0]
v.reset(OpPPC64ANDN)
v.AddArg(x)
v.AddArg(y)
return true
}
// match: (AND (MOVDconst [c]) (MOVDconst [d])) // match: (AND (MOVDconst [c]) (MOVDconst [d]))
// cond: // cond:
// result: (MOVDconst [c&d]) // result: (MOVDconst [c&d])