diff options
Diffstat (limited to 'test/inline.go')
-rw-r--r-- | test/inline.go | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/inline.go b/test/inline.go index 37965c0d9d..bc23768d01 100644 --- a/test/inline.go +++ b/test/inline.go @@ -1,4 +1,4 @@ -// errorcheck -0 -m +// errorcheck -0 -m -d=inlfuncswithclosures=1 // Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -262,3 +262,31 @@ func gd2() int { // ERROR "can inline gd2" func gd3() func() { // ERROR "can inline gd3" return ii } + +// 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] = 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. +func Conv(v uint64) uint64 { // ERROR "can inline Conv" + return conv2(conv2(conv2(v))) // ERROR "inlining call to (conv1|conv2)" +} +func conv2(v uint64) uint64 { // ERROR "can inline conv2" + return conv1(conv1(conv1(conv1(v)))) // ERROR "inlining call to conv1" +} +func conv1(v uint64) uint64 { // ERROR "can inline conv1" + return uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(uint64(v))))))))))) +} |