mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
cmd/compile: use CMPWU for 32-bit or smaller unsigned Geq on ppc64{,le}
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>
This commit is contained in:
parent
21a8db1c5f
commit
96ea0918e6
|
@ -338,9 +338,9 @@
|
|||
(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.
|
||||
|
|
|
@ -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)
|
||||
|
|
63
test/fixedbugs/issue18808.go
Normal file
63
test/fixedbugs/issue18808.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Reference in a new issue