Skip to content

Commit 7a574ff

Browse files
cherrymuidr2chase
authored andcommitted
cmd/compile: fix boolean comparison on PPC64
Following CL 405114, for PPC64. Should fix PPC64 builds. Updates #52788. Change-Id: I193ac31cfba18b4f907dd2523b51368251fd6fad Reviewed-on: https://go-review.googlesource.com/c/go/+/405116 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent 482669d commit 7a574ff

File tree

3 files changed

+88
-44
lines changed

3 files changed

+88
-44
lines changed

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,19 @@
446446
(If (FGreaterThan cc) yes no) => (FGT cc yes no)
447447
(If (FGreaterEqual cc) yes no) => (FGE cc yes no)
448448

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

451451
// Absorb boolean tests into block
452-
(NE (CMPWconst [0] (Equal cc)) yes no) => (EQ cc yes no)
453-
(NE (CMPWconst [0] (NotEqual cc)) yes no) => (NE cc yes no)
454-
(NE (CMPWconst [0] (LessThan cc)) yes no) => (LT cc yes no)
455-
(NE (CMPWconst [0] (LessEqual cc)) yes no) => (LE cc yes no)
456-
(NE (CMPWconst [0] (GreaterThan cc)) yes no) => (GT cc yes no)
457-
(NE (CMPWconst [0] (GreaterEqual cc)) yes no) => (GE cc yes no)
458-
(NE (CMPWconst [0] (FLessThan cc)) yes no) => (FLT cc yes no)
459-
(NE (CMPWconst [0] (FLessEqual cc)) yes no) => (FLE cc yes no)
460-
(NE (CMPWconst [0] (FGreaterThan cc)) yes no) => (FGT cc yes no)
461-
(NE (CMPWconst [0] (FGreaterEqual cc)) yes no) => (FGE cc yes no)
452+
(NE (CMPWconst [0] (ANDconst [1] (Equal cc))) yes no) => (EQ cc yes no)
453+
(NE (CMPWconst [0] (ANDconst [1] (NotEqual cc))) yes no) => (NE cc yes no)
454+
(NE (CMPWconst [0] (ANDconst [1] (LessThan cc))) yes no) => (LT cc yes no)
455+
(NE (CMPWconst [0] (ANDconst [1] (LessEqual cc))) yes no) => (LE cc yes no)
456+
(NE (CMPWconst [0] (ANDconst [1] (GreaterThan cc))) yes no) => (GT cc yes no)
457+
(NE (CMPWconst [0] (ANDconst [1] (GreaterEqual cc))) yes no) => (GE cc yes no)
458+
(NE (CMPWconst [0] (ANDconst [1] (FLessThan cc))) yes no) => (FLT cc yes no)
459+
(NE (CMPWconst [0] (ANDconst [1] (FLessEqual cc))) yes no) => (FLE cc yes no)
460+
(NE (CMPWconst [0] (ANDconst [1] (FGreaterThan cc))) yes no) => (FGT cc yes no)
461+
(NE (CMPWconst [0] (ANDconst [1] (FGreaterEqual cc))) yes no) => (FGE cc yes no)
462462

463463
// Elide compares of bit tests // TODO need to make both CC and result of ANDCC available.
464464
(EQ (CMPconst [0] (ANDconst [c] x)) yes no) => (EQ (ANDCCconst [c] x) yes no)

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

+76-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/objdump/objdump_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ var ppcNeed = []string{
102102
var ppcGnuNeed = []string{
103103
"mflr",
104104
"lbz",
105-
"cmpw",
105+
"beq",
106106
}
107107

108108
func mustHaveDisasm(t *testing.T) {

0 commit comments

Comments
 (0)