aboutsummaryrefslogtreecommitdiff
path: root/test/inline.go
diff options
context:
space:
mode:
authorEgon Elbre <egonelbre@gmail.com>2021-02-24 21:08:52 +0200
committerBryan C. Mills <bcmills@google.com>2021-02-25 02:22:12 +0000
commitd822ffebc59d27190ac145a71c726dad35769225 (patch)
tree3d11957aead35c63b8e6dfd29afdc3a74deb5743 /test/inline.go
parentff614b13d90961f55b1058bd798c6d4e92d3939c (diff)
downloadgo-d822ffebc59d27190ac145a71c726dad35769225.tar.gz
go-d822ffebc59d27190ac145a71c726dad35769225.zip
test: fix inline.go test for linux-amd64-noopt
math.Float32bits was not being inlined across package boundaries. Create a private func that can be inlined with -l. Change-Id: Ic50bf4727dd8ade09d011eb204006b7ee88db34a Reviewed-on: https://go-review.googlesource.com/c/go/+/295989 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'test/inline.go')
-rw-r--r--test/inline.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/inline.go b/test/inline.go
index 44c746b282..bc23768d01 100644
--- a/test/inline.go
+++ b/test/inline.go
@@ -10,7 +10,6 @@
package foo
import (
- "math"
"runtime"
"unsafe"
)
@@ -267,12 +266,18 @@ func gd3() func() { // ERROR "can inline gd3"
// Issue #42788 - ensure ODEREF OCONVNOP* OADDR is low cost.
func EncodeQuad(d []uint32, x [6]float32) { // ERROR "can inline EncodeQuad" "d does not escape"
_ = d[:6]
- d[0] = math.Float32bits(x[0]) // ERROR "inlining call to math.Float32bits"
- d[1] = math.Float32bits(x[1]) // ERROR "inlining call to math.Float32bits"
- d[2] = math.Float32bits(x[2]) // ERROR "inlining call to math.Float32bits"
- d[3] = math.Float32bits(x[3]) // ERROR "inlining call to math.Float32bits"
- d[4] = math.Float32bits(x[4]) // ERROR "inlining call to math.Float32bits"
- d[5] = math.Float32bits(x[5]) // ERROR "inlining call to math.Float32bits"
+ d[0] = float32bits(x[0]) // ERROR "inlining call to float32bits"
+ d[1] = float32bits(x[1]) // ERROR "inlining call to float32bits"
+ d[2] = float32bits(x[2]) // ERROR "inlining call to float32bits"
+ d[3] = float32bits(x[3]) // ERROR "inlining call to float32bits"
+ d[4] = float32bits(x[4]) // ERROR "inlining call to float32bits"
+ d[5] = float32bits(x[5]) // ERROR "inlining call to float32bits"
+}
+
+// float32bits is a copy of math.Float32bits to ensure that
+// these tests pass with `-gcflags=-l`.
+func float32bits(f float32) uint32 { // ERROR "can inline float32bits"
+ return *(*uint32)(unsafe.Pointer(&f))
}
// Ensure OCONVNOP is zero cost.