Skip to content

Commit d74e69c

Browse files
Milan KnezevicFiloSottile
Milan Knezevic
authored andcommitted
[release-branch.go1.10] cmd/compile/internal/gc: OMUL should be evaluated when using soft-float
When using soft-float, OMUL might be rewritten to function call so we should ensure it was evaluated first. Updates #28688 Fixes #28959 Change-Id: I30b87501782fff62d35151f394a1c22b0d490c6c Reviewed-on: https://go-review.googlesource.com/c/148837 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> (cherry picked from commit c92e73b) Reviewed-on: https://go-review.googlesource.com/c/151343 Reviewed-by: Filippo Valsorda <[email protected]>
1 parent 25bee96 commit d74e69c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/cmd/compile/internal/gc/subr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ func calcHasCall(n *Node) bool {
11681168

11691169
// When using soft-float, these ops might be rewritten to function calls
11701170
// so we ensure they are evaluated first.
1171-
case OADD, OSUB, OMINUS:
1171+
case OADD, OSUB, OMINUS, OMUL:
11721172
if thearch.SoftFloat && (isFloat[n.Type.Etype] || isComplex[n.Type.Etype]) {
11731173
return true
11741174
}

test/fixedbugs/issue28688.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// run -gcflags=-d=softfloat
2+
3+
// Copyright 2018 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
import (
10+
"fmt"
11+
)
12+
13+
// When using soft-float, OMUL might be rewritten to function
14+
// call so we should ensure it was evaluated first. Stack frame
15+
// setup for "test" function call should happen after call to runtime.fmul32
16+
17+
var x int32 = 1
18+
19+
func main() {
20+
var y float32 = 1.0
21+
test(x, y*y)
22+
}
23+
24+
//go:noinline
25+
func test(id int32, a float32) {
26+
27+
if id != x {
28+
fmt.Printf("got: %d, want: %d\n", id, x)
29+
panic("FAIL")
30+
}
31+
}

0 commit comments

Comments
 (0)