Commit 95f3e474 authored by Lynn Boger's avatar Lynn Boger Committed by David Chase

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: default avatarDavid Chase <drchase@google.com>
parent 7124056f
...@@ -267,6 +267,9 @@ ...@@ -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
......
...@@ -4471,6 +4471,24 @@ func rewriteValuePPC64_OpPPC64ADDconst(v *Value, config *Config) bool { ...@@ -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])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment