]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.14] cmd/compile: mark s390x int <-> float conversions as clobberi...
authorMichael Munday <mike.munday@ibm.com>
Mon, 13 Jul 2020 09:16:02 +0000 (02:16 -0700)
committerDmitri Shuralyov <dmitshur@golang.org>
Fri, 21 Aug 2020 23:51:59 +0000 (23:51 +0000)
These conversion instructions set the condition code and so should
be marked as clobbering flags.

Updates #39651.
Fixes #39690.

Change-Id: I1e3f2cf33337128d321b52ac72f46d1b8798ebd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/242237
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/S390XOps.go
src/cmd/compile/internal/ssa/opGen.go
test/fixedbugs/issue39651.go [new file with mode: 0644]

index 6517957fd4742e9812964570061061c4c9f3fa8d..62d56bf182f529aa9bacdb77b21e28ba3b19cd48 100644 (file)
@@ -391,18 +391,20 @@ func init() {
 
                {name: "MOVDconst", reg: gp01, asm: "MOVD", typ: "UInt64", aux: "Int64", rematerializeable: true}, // auxint
 
-               {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: "LEDBR", argLength: 1, reg: fp11, asm: "LEDBR"},   // convert float64 to float32
-               {name: "LDEBR", argLength: 1, reg: fp11, asm: "LDEBR"},   // convert float32 to float64
+               {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", 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: "LEDBR", argLength: 1, reg: fp11, asm: "LEDBR"}, // convert float64 to float32
+               {name: "LDEBR", argLength: 1, reg: fp11, asm: "LDEBR"}, // convert float32 to float64
 
                {name: "MOVDaddr", argLength: 1, reg: addr, aux: "SymOff", rematerializeable: true, symEffect: "Read"}, // arg0 + auxint + offset encoded in aux
                {name: "MOVDaddridx", argLength: 2, reg: addridx, aux: "SymOff", symEffect: "Read"},                    // arg0 + arg1 + auxint + aux
index 86428a3e84776b813a2bccf7052dc93cf23a5f04..dd05eecc93d7a476da171a7c2d3571102f79f412 100644 (file)
@@ -28192,9 +28192,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CFDBRA",
-               argLen: 1,
-               asm:    s390x.ACFDBRA,
+               name:         "CFDBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACFDBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
@@ -28205,9 +28206,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CGDBRA",
-               argLen: 1,
-               asm:    s390x.ACGDBRA,
+               name:         "CGDBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACGDBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
@@ -28218,9 +28220,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CFEBRA",
-               argLen: 1,
-               asm:    s390x.ACFEBRA,
+               name:         "CFEBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACFEBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
@@ -28231,9 +28234,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CGEBRA",
-               argLen: 1,
-               asm:    s390x.ACGEBRA,
+               name:         "CGEBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACGEBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
@@ -28244,9 +28248,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CEFBRA",
-               argLen: 1,
-               asm:    s390x.ACEFBRA,
+               name:         "CEFBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACEFBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14
@@ -28257,9 +28262,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CDFBRA",
-               argLen: 1,
-               asm:    s390x.ACDFBRA,
+               name:         "CDFBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACDFBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14
@@ -28270,9 +28276,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CEGBRA",
-               argLen: 1,
-               asm:    s390x.ACEGBRA,
+               name:         "CEGBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACEGBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14
@@ -28283,9 +28290,10 @@ var opcodeTable = [...]opInfo{
                },
        },
        {
-               name:   "CDGBRA",
-               argLen: 1,
-               asm:    s390x.ACDGBRA,
+               name:         "CDGBRA",
+               argLen:       1,
+               clobberFlags: true,
+               asm:          s390x.ACDGBRA,
                reg: regInfo{
                        inputs: []inputInfo{
                                {0, 23551}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R11 R12 R14
diff --git a/test/fixedbugs/issue39651.go b/test/fixedbugs/issue39651.go
new file mode 100644 (file)
index 0000000..256a34d
--- /dev/null
@@ -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")
+       }
+}