Skip to content

Commit

Permalink
[release-branch.go1.18] cmd/compile: fix boolean comparison on PPC64
Browse files Browse the repository at this point in the history
Following CL 421457, for PPC64.

Should fix PPC64 builds.

Updates #52788.
Updates #53397.

Change-Id: I193ac31cfba18b4f907dd2523b51368251fd6fad
Reviewed-on: https://go-review.googlesource.com/c/go/+/405116
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/421459
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
  • Loading branch information
cherrymui authored and thanm committed Aug 8, 2022
1 parent e1099eb commit 276a7bf
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 44 deletions.
22 changes: 11 additions & 11 deletions src/cmd/compile/internal/ssa/gen/PPC64.rules
Expand Up @@ -445,19 +445,19 @@
(If (FGreaterThan cc) yes no) => (FGT cc yes no)
(If (FGreaterEqual cc) yes no) => (FGE cc yes no)

(If cond yes no) => (NE (CMPWconst [0] cond) yes no)
(If cond yes no) => (NE (CMPWconst [0] (ANDconst <typ.UInt32> [1] cond)) yes no)

// Absorb boolean tests into block
(NE (CMPWconst [0] (Equal cc)) yes no) => (EQ cc yes no)
(NE (CMPWconst [0] (NotEqual cc)) yes no) => (NE cc yes no)
(NE (CMPWconst [0] (LessThan cc)) yes no) => (LT cc yes no)
(NE (CMPWconst [0] (LessEqual cc)) yes no) => (LE cc yes no)
(NE (CMPWconst [0] (GreaterThan cc)) yes no) => (GT cc yes no)
(NE (CMPWconst [0] (GreaterEqual cc)) yes no) => (GE cc yes no)
(NE (CMPWconst [0] (FLessThan cc)) yes no) => (FLT cc yes no)
(NE (CMPWconst [0] (FLessEqual cc)) yes no) => (FLE cc yes no)
(NE (CMPWconst [0] (FGreaterThan cc)) yes no) => (FGT cc yes no)
(NE (CMPWconst [0] (FGreaterEqual cc)) yes no) => (FGE cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (Equal cc))) yes no) => (EQ cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (NotEqual cc))) yes no) => (NE cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (LessThan cc))) yes no) => (LT cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (LessEqual cc))) yes no) => (LE cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (GreaterThan cc))) yes no) => (GT cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (GreaterEqual cc))) yes no) => (GE cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (FLessThan cc))) yes no) => (FLT cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (FLessEqual cc))) yes no) => (FLE cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (FGreaterThan cc))) yes no) => (FGT cc yes no)
(NE (CMPWconst [0] (ANDconst [1] (FGreaterEqual cc))) yes no) => (FGE cc yes no)

// Elide compares of bit tests // TODO need to make both CC and result of ANDCC available.
(EQ (CMPconst [0] (ANDconst [c] x)) yes no) => (EQ (ANDCCconst [c] x) yes no)
Expand Down
108 changes: 76 additions & 32 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.

2 changes: 1 addition & 1 deletion src/cmd/objdump/objdump_test.go
Expand Up @@ -102,7 +102,7 @@ var ppcNeed = []string{
var ppcGnuNeed = []string{
"mflr",
"lbz",
"cmpw",
"beq",
}

func mustHaveDisasm(t *testing.T) {
Expand Down

0 comments on commit 276a7bf

Please sign in to comment.