]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use CMPWU for 32-bit or smaller unsigned Geq on ppc64{,le}
authorMichael Munday <munday@ca.ibm.com>
Fri, 27 Jan 2017 04:31:28 +0000 (23:31 -0500)
committerMichael Munday <munday@ca.ibm.com>
Fri, 27 Jan 2017 16:04:04 +0000 (16:04 +0000)
Fixes #18808.

Change-Id: I49b266380b9d6804c9f6563ebac9c7c0e05f37f6
Reviewed-on: https://go-review.googlesource.com/35890
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go
test/fixedbugs/issue18808.go [new file with mode: 0644]

index 0e0f1f9c1e79c9bc19b1b3d4640760f8cc471914..cad753e591d8c995feece7eedea7a471a890940d 100644 (file)
 (Geq32F x y) -> (FGreaterEqual (FCMPU x y))
 (Geq64F x y) -> (FGreaterEqual (FCMPU x y))
 
-(Geq8U x y)  -> (GreaterEqual (CMPU (ZeroExt8to32 x) (ZeroExt8to32 y)))
-(Geq16U x y) -> (GreaterEqual (CMPU (ZeroExt16to32 x) (ZeroExt16to32 y)))
-(Geq32U x y) -> (GreaterEqual (CMPU x y))
+(Geq8U x y)  -> (GreaterEqual (CMPWU (ZeroExt8to32 x) (ZeroExt8to32 y)))
+(Geq16U x y) -> (GreaterEqual (CMPWU (ZeroExt16to32 x) (ZeroExt16to32 y)))
+(Geq32U x y) -> (GreaterEqual (CMPWU x y))
 (Geq64U x y) -> (GreaterEqual (CMPU x y))
 
 // Absorb pseudo-ops into blocks.
index 8c8373b8aa019b24057184c631d733b70ce6168d..031459c1ffbedb0e42553e33b3fed1abd7e7ce23 100644 (file)
@@ -1543,12 +1543,12 @@ func rewriteValuePPC64_OpGeq16U(v *Value, config *Config) bool {
        _ = b
        // match: (Geq16U x y)
        // cond:
-       // result: (GreaterEqual (CMPU (ZeroExt16to32 x) (ZeroExt16to32 y)))
+       // result: (GreaterEqual (CMPWU (ZeroExt16to32 x) (ZeroExt16to32 y)))
        for {
                x := v.Args[0]
                y := v.Args[1]
                v.reset(OpPPC64GreaterEqual)
-               v0 := b.NewValue0(v.Line, OpPPC64CMPU, TypeFlags)
+               v0 := b.NewValue0(v.Line, OpPPC64CMPWU, TypeFlags)
                v1 := b.NewValue0(v.Line, OpZeroExt16to32, config.fe.TypeUInt32())
                v1.AddArg(x)
                v0.AddArg(v1)
@@ -1598,12 +1598,12 @@ func rewriteValuePPC64_OpGeq32U(v *Value, config *Config) bool {
        _ = b
        // match: (Geq32U x y)
        // cond:
-       // result: (GreaterEqual (CMPU x y))
+       // result: (GreaterEqual (CMPWU x y))
        for {
                x := v.Args[0]
                y := v.Args[1]
                v.reset(OpPPC64GreaterEqual)
-               v0 := b.NewValue0(v.Line, OpPPC64CMPU, TypeFlags)
+               v0 := b.NewValue0(v.Line, OpPPC64CMPWU, TypeFlags)
                v0.AddArg(x)
                v0.AddArg(y)
                v.AddArg(v0)
@@ -1687,12 +1687,12 @@ func rewriteValuePPC64_OpGeq8U(v *Value, config *Config) bool {
        _ = b
        // match: (Geq8U x y)
        // cond:
-       // result: (GreaterEqual (CMPU (ZeroExt8to32 x) (ZeroExt8to32 y)))
+       // result: (GreaterEqual (CMPWU (ZeroExt8to32 x) (ZeroExt8to32 y)))
        for {
                x := v.Args[0]
                y := v.Args[1]
                v.reset(OpPPC64GreaterEqual)
-               v0 := b.NewValue0(v.Line, OpPPC64CMPU, TypeFlags)
+               v0 := b.NewValue0(v.Line, OpPPC64CMPWU, TypeFlags)
                v1 := b.NewValue0(v.Line, OpZeroExt8to32, config.fe.TypeUInt32())
                v1.AddArg(x)
                v0.AddArg(v1)
diff --git a/test/fixedbugs/issue18808.go b/test/fixedbugs/issue18808.go
new file mode 100644 (file)
index 0000000..c98386e
--- /dev/null
@@ -0,0 +1,63 @@
+// run
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+const lim = 0x80000000
+
+//go:noinline
+func eq(x uint32) {
+       if x == lim {
+               return
+       }
+       panic("x == lim returned false")
+}
+
+//go:noinline
+func neq(x uint32) {
+       if x != lim {
+               panic("x != lim returned true")
+       }
+}
+
+//go:noinline
+func gt(x uint32) {
+       if x > lim {
+               return
+       }
+       panic("x > lim returned false")
+}
+
+//go:noinline
+func gte(x uint32) {
+       if x >= lim {
+               return
+       }
+       panic("x >= lim returned false")
+}
+
+//go:noinline
+func lt(x uint32) {
+       if x < lim {
+               panic("x < lim returned true")
+       }
+}
+
+//go:noinline
+func lte(x uint32) {
+       if x <= lim {
+               panic("x <= lim returned true")
+       }
+}
+
+func main() {
+       eq(lim)
+       neq(lim)
+       gt(lim+1)
+       gte(lim+1)
+       lt(lim+1)
+       lte(lim+1)
+}