1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:24:47 -07:00

cmd/compile: mark s390x int <-> float conversions as clobbering flags

These conversion instructions set the condition code and so should
be marked as clobbering flags.

Fixes #39651.

Change-Id: I91cc9687ea70ef0551bb3139c1875071c349d43e
Reviewed-on: https://go-review.googlesource.com/c/go/+/238628
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Michael Munday 2020-06-18 05:25:07 -07:00
parent 4379fa1740
commit 377c1536f5
3 changed files with 109 additions and 66 deletions

View File

@ -396,22 +396,23 @@ func init() {
{name: "LDGR", argLength: 1, reg: gpfp, asm: "LDGR"}, // move int64 to float64 (no conversion)
{name: "LGDR", argLength: 1, reg: fpgp, asm: "LGDR"}, // move float64 to int64 (no conversion)
{name: "CFDBRA", argLength: 1, reg: fpgp, asm: "CFDBRA"}, // convert float64 to int32
{name: "CGDBRA", argLength: 1, reg: fpgp, asm: "CGDBRA"}, // convert float64 to int64
{name: "CFEBRA", argLength: 1, reg: fpgp, asm: "CFEBRA"}, // convert float32 to int32
{name: "CGEBRA", argLength: 1, reg: fpgp, asm: "CGEBRA"}, // convert float32 to int64
{name: "CEFBRA", argLength: 1, reg: gpfp, asm: "CEFBRA"}, // convert int32 to float32
{name: "CDFBRA", argLength: 1, reg: gpfp, asm: "CDFBRA"}, // convert int32 to float64
{name: "CEGBRA", argLength: 1, reg: gpfp, asm: "CEGBRA"}, // convert int64 to float32
{name: "CDGBRA", argLength: 1, reg: gpfp, asm: "CDGBRA"}, // convert int64 to float64
{name: "CLFEBR", argLength: 1, reg: fpgp, asm: "CLFEBR"}, // convert float32 to uint32
{name: "CLFDBR", argLength: 1, reg: fpgp, asm: "CLFDBR"}, // convert float64 to uint32
{name: "CLGEBR", argLength: 1, reg: fpgp, asm: "CLGEBR"}, // convert float32 to uint64
{name: "CLGDBR", argLength: 1, reg: fpgp, asm: "CLGDBR"}, // convert float64 to uint64
{name: "CELFBR", argLength: 1, reg: gpfp, asm: "CELFBR"}, // convert uint32 to float32
{name: "CDLFBR", argLength: 1, reg: gpfp, asm: "CDLFBR"}, // convert uint32 to float64
{name: "CELGBR", argLength: 1, reg: gpfp, asm: "CELGBR"}, // convert uint64 to float32
{name: "CDLGBR", argLength: 1, reg: gpfp, asm: "CDLGBR"}, // convert uint64 to float64
{name: "CFDBRA", argLength: 1, reg: fpgp, asm: "CFDBRA", clobberFlags: true}, // convert float64 to int32
{name: "CGDBRA", argLength: 1, reg: fpgp, asm: "CGDBRA", clobberFlags: true}, // convert float64 to int64
{name: "CFEBRA", argLength: 1, reg: fpgp, asm: "CFEBRA", clobberFlags: true}, // convert float32 to int32
{name: "CGEBRA", argLength: 1, reg: fpgp, asm: "CGEBRA", clobberFlags: true}, // convert float32 to int64
{name: "CEFBRA", argLength: 1, reg: gpfp, asm: "CEFBRA", clobberFlags: true}, // convert int32 to float32
{name: "CDFBRA", argLength: 1, reg: gpfp, asm: "CDFBRA", clobberFlags: true}, // convert int32 to float64
{name: "CEGBRA", argLength: 1, reg: gpfp, asm: "CEGBRA", clobberFlags: true}, // convert int64 to float32
{name: "CDGBRA", argLength: 1, reg: gpfp, asm: "CDGBRA", clobberFlags: true}, // convert int64 to float64
{name: "CLFEBR", argLength: 1, reg: fpgp, asm: "CLFEBR", clobberFlags: true}, // convert float32 to uint32
{name: "CLFDBR", argLength: 1, reg: fpgp, asm: "CLFDBR", clobberFlags: true}, // convert float64 to uint32
{name: "CLGEBR", argLength: 1, reg: fpgp, asm: "CLGEBR", clobberFlags: true}, // convert float32 to uint64
{name: "CLGDBR", argLength: 1, reg: fpgp, asm: "CLGDBR", clobberFlags: true}, // convert float64 to uint64
{name: "CELFBR", argLength: 1, reg: gpfp, asm: "CELFBR", clobberFlags: true}, // convert uint32 to float32
{name: "CDLFBR", argLength: 1, reg: gpfp, asm: "CDLFBR", clobberFlags: true}, // convert uint32 to float64
{name: "CELGBR", argLength: 1, reg: gpfp, asm: "CELGBR", clobberFlags: true}, // convert uint64 to float32
{name: "CDLGBR", argLength: 1, reg: gpfp, asm: "CDLGBR", clobberFlags: true}, // convert uint64 to float64
{name: "LEDBR", argLength: 1, reg: fp11, asm: "LEDBR"}, // convert float64 to float32
{name: "LDEBR", argLength: 1, reg: fp11, asm: "LDEBR"}, // convert float32 to float64

View File

@ -30193,6 +30193,7 @@ var opcodeTable = [...]opInfo{
{
name: "CFDBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACFDBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30206,6 +30207,7 @@ var opcodeTable = [...]opInfo{
{
name: "CGDBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACGDBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30219,6 +30221,7 @@ var opcodeTable = [...]opInfo{
{
name: "CFEBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACFEBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30232,6 +30235,7 @@ var opcodeTable = [...]opInfo{
{
name: "CGEBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACGEBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30245,6 +30249,7 @@ var opcodeTable = [...]opInfo{
{
name: "CEFBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACEFBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30258,6 +30263,7 @@ var opcodeTable = [...]opInfo{
{
name: "CDFBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACDFBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30271,6 +30277,7 @@ var opcodeTable = [...]opInfo{
{
name: "CEGBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACEGBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30284,6 +30291,7 @@ var opcodeTable = [...]opInfo{
{
name: "CDGBRA",
argLen: 1,
clobberFlags: true,
asm: s390x.ACDGBRA,
reg: regInfo{
inputs: []inputInfo{
@ -30297,6 +30305,7 @@ var opcodeTable = [...]opInfo{
{
name: "CLFEBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACLFEBR,
reg: regInfo{
inputs: []inputInfo{
@ -30310,6 +30319,7 @@ var opcodeTable = [...]opInfo{
{
name: "CLFDBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACLFDBR,
reg: regInfo{
inputs: []inputInfo{
@ -30323,6 +30333,7 @@ var opcodeTable = [...]opInfo{
{
name: "CLGEBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACLGEBR,
reg: regInfo{
inputs: []inputInfo{
@ -30336,6 +30347,7 @@ var opcodeTable = [...]opInfo{
{
name: "CLGDBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACLGDBR,
reg: regInfo{
inputs: []inputInfo{
@ -30349,6 +30361,7 @@ var opcodeTable = [...]opInfo{
{
name: "CELFBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACELFBR,
reg: regInfo{
inputs: []inputInfo{
@ -30362,6 +30375,7 @@ var opcodeTable = [...]opInfo{
{
name: "CDLFBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACDLFBR,
reg: regInfo{
inputs: []inputInfo{
@ -30375,6 +30389,7 @@ var opcodeTable = [...]opInfo{
{
name: "CELGBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACELGBR,
reg: regInfo{
inputs: []inputInfo{
@ -30388,6 +30403,7 @@ var opcodeTable = [...]opInfo{
{
name: "CDLGBR",
argLen: 1,
clobberFlags: true,
asm: s390x.ACDLGBR,
reg: regInfo{
inputs: []inputInfo{

View File

@ -0,0 +1,26 @@
// run
// Copyright 2020 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.
// Test that float -> integer conversion doesn't clobber
// flags.
package main
//go:noinline
func f(x, y float64, a, b *bool, r *int64) {
*a = x < y // set flags
*r = int64(x) // clobber flags
*b = x == y // use flags
}
func main() {
var a, b bool
var r int64
f(1, 1, &a, &b, &r)
if a || !b {
panic("comparison incorrect")
}
}