]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add rule to use ANDN for a&^b on ppc64x
authorLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 24 Oct 2016 19:19:18 +0000 (14:19 -0500)
committerDavid Chase <drchase@google.com>
Mon, 24 Oct 2016 19:51:44 +0000 (19:51 +0000)
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>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go

index ba1ffa5e12ed2758d916a8540259c4d8795e93e4..005b97a77d9a4083bf1cd9d87633e93b855d6c13 100644 (file)
 (OrB x y) -> (OR x y)
 (Not x) -> (XORconst [1] x)
 
+// Use ANDN for AND x NOT y
+(AND x (XORconst [-1] y)) -> (ANDN x y)
+
 // Lowering comparisons
 (EqB x y)  -> (ANDconst [1] (EQV x y))
 // Sign extension dependence on operand sign sets up for sign/zero-extension elision later
index bea94e44d81be8b4b99fce38027d5e45410241dc..5b4574efd43a6589575375ee2b53274d8ecae342 100644 (file)
@@ -4471,6 +4471,24 @@ func rewriteValuePPC64_OpPPC64ADDconst(v *Value, config *Config) bool {
 func rewriteValuePPC64_OpPPC64AND(v *Value, config *Config) bool {
        b := v.Block
        _ = 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]))
        // cond:
        // result: (MOVDconst [c&d])