Skip to content

Commit

Permalink
cmd/compile: combine OR + NOT into ORN on PPC64
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Lynn Boger <[email protected]>
Reviewed-by: David Chase <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
pmur committed May 4, 2022
1 parent ffe48e0 commit c570f0e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cmd/compile/internal/ssa/gen/PPC64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
18 changes: 18 additions & 0 deletions src/cmd/compile/internal/ssa/rewritePPC64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions test/codegen/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c570f0e

Please sign in to comment.