import (
"math"
+ "os"
+ "runtime"
"testing"
)
func TestFloat32StoreToLoadConstantFold(t *testing.T) {
// Test that math.Float32{,from}bits constant fold correctly.
- // In particular we need to be careful that signalling NaN (sNaN) values
+ // In particular we need to be careful that signaling NaN (sNaN) values
// are not converted to quiet NaN (qNaN) values during compilation.
// See issue #27193 for more information.
- // signalling NaNs
+ // TODO: this method for detecting 387 won't work if the compiler has been
+ // built using GOARCH=386 GO386=387 and either the target is a different
+ // architecture or the GO386=387 environment variable is not set when the
+ // test is run.
+ if runtime.GOARCH == "386" && os.Getenv("GO386") == "387" {
+ t.Skip("signaling NaNs are not propagated on 387 (issue #27516)")
+ }
+
+ // signaling NaNs
{
const nan = uint32(0x7f800001) // sNaN
if x := math.Float32bits(math.Float32frombits(nan)); x != nan {