This shows up in a few crypto functions, and other
assorted places.
Change-Id: I5a7f4c25ddd4a6499dc295ef693b9fe43d2448ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/404057
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
(OrB ...) => (OR ...)
(Not x) => (XORconst [1] x)
-// Use ANDN for AND x NOT y
+// Merge logical operations
(AND x (NOR y y)) => (ANDN x y)
+(OR x (NOR y y)) => (ORN x y)
// Lowering comparisons
(EqB x y) => (ANDconst [1] (EQV x y))
}
break
}
+ // match: (OR x (NOR y y))
+ // result: (ORN x y)
+ for {
+ for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 {
+ x := v_0
+ if v_1.Op != OpPPC64NOR {
+ continue
+ }
+ y := v_1.Args[1]
+ if y != v_1.Args[0] {
+ continue
+ }
+ v.reset(OpPPC64ORN)
+ v.AddArg2(x, y)
+ return true
+ }
+ break
+ }
// match: (OR (MOVDconst [c]) (MOVDconst [d]))
// result: (MOVDconst [c|d])
for {
// use z by returning it
return z
}
+
+// Verify (OR x (NOT y)) rewrites to (ORN x y) where supported
+func ornot(x, y int) int {
+ // ppc64:"ORN"
+ // ppc64le:"ORN"
+ z := x | ^y
+ return z
+}