Skip to content

Commit 259735f

Browse files
pmurcherrymui
authored andcommitted
cmd/compile: enable branchelim pass on ppc64
and fix/cleanup lowering of the SSA operator created by the pass. Change-Id: I7e6153194fd16013e3b24da8aa40683adafa3d15 Reviewed-on: https://go-review.googlesource.com/c/go/+/344573 Run-TryBot: Paul Murphy <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Lynn Boger <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Trust: Josh Bleecher Snyder <[email protected]>
1 parent bb49eb3 commit 259735f

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

src/cmd/compile/internal/ssa/branchelim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import "cmd/internal/src"
2222
func branchelim(f *Func) {
2323
// FIXME: add support for lowering CondSelects on more architectures
2424
switch f.Config.arch {
25-
case "arm64", "amd64", "wasm":
25+
case "arm64", "ppc64le", "ppc64", "amd64", "wasm":
2626
// implemented
2727
default:
2828
return

src/cmd/compile/internal/ssa/gen/PPC64.rules

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,10 @@
561561
((EQ|NE|LT|LE|GT|GE) (CMPconst [0] z:(OR x y)) yes no) && z.Uses == 1 => ((EQ|NE|LT|LE|GT|GE) (ORCC x y) yes no)
562562
((EQ|NE|LT|LE|GT|GE) (CMPconst [0] z:(XOR x y)) yes no) && z.Uses == 1 => ((EQ|NE|LT|LE|GT|GE) (XORCC x y) yes no)
563563

564-
(CondSelect x y bool) && flagArg(bool) != nil => (ISEL [2] x y bool)
565-
(CondSelect x y bool) && flagArg(bool) == nil => (ISEL [2] x y (CMPWconst [0] bool))
564+
// Only lower after bool is lowered. It should always lower. This helps ensure the folding below happens reliably.
565+
(CondSelect x y bool) && flagArg(bool) == nil => (ISEL [6] x y (CMPWconst [0] bool))
566+
// Fold any CR -> GPR -> CR transfers when applying the above rule.
567+
(ISEL [6] x y (CMPWconst [0] (ISELB [c] one cmp))) => (ISEL [c] x y cmp)
566568

567569
// Lowering loads
568570
(Load <t> ptr mem) && (is64BitInt(t) || isPtr(t)) => (MOVDload ptr mem)
@@ -849,6 +851,7 @@
849851
(NEG (ADDconst [c] x)) && is32Bit(-c) => (SUBFCconst [-c] x)
850852
(NEG (SUBFCconst [c] x)) && is32Bit(-c) => (ADDconst [-c] x)
851853
(NEG (SUB x y)) => (SUB y x)
854+
(NEG (NEG x)) => x
852855

853856
// Use register moves instead of stores and loads to move int<=>float values
854857
// Common with math Float64bits, Float64frombits

src/cmd/compile/internal/ssa/rewritePPC64.go

Lines changed: 34 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)