mirror of
https://github.com/golang/go
synced 2024-11-22 18:34:51 -07:00
cmd/compile: combine OR + NOT into ORN on PPC64
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>
This commit is contained in:
parent
ffe48e00ad
commit
c570f0eda2
@ -381,8 +381,9 @@
|
||||
(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))
|
||||
|
@ -11687,6 +11687,24 @@ func rewriteValuePPC64_OpPPC64OR(v *Value) bool {
|
||||
}
|
||||
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 {
|
||||
|
@ -22,3 +22,11 @@ func andWithUse(x, y int) int {
|
||||
// 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user