Skip to content

Commit c92e73b

Browse files
Milan Knezeviccherrymui
Milan Knezevic
authored andcommitted
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. Fixes #28688 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]>
1 parent 0a72e8e commit c92e73b

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
@@ -1006,7 +1006,7 @@ func calcHasCall(n *Node) bool {
10061006

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

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)