Skip to content

Commit 16687a3

Browse files
committed
cmd/compile: skip float32 constant folding test on 387 builder
The 387 unit always quietens float64 and float32 signaling NaNs, even when just loading and storing them. This makes it difficult to propagate such values in the compiler. This is a hard problem to fix and it is also very obscure. Updates #27516. Change-Id: I03d88e31f14c86fa682fcea4b6d1fba18968aee8 Reviewed-on: https://go-review.googlesource.com/135195 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 9f59918 commit 16687a3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package gc
66

77
import (
88
"math"
9+
"os"
10+
"runtime"
911
"testing"
1012
)
1113

@@ -364,11 +366,19 @@ func TestFloatConvertFolded(t *testing.T) {
364366

365367
func TestFloat32StoreToLoadConstantFold(t *testing.T) {
366368
// Test that math.Float32{,from}bits constant fold correctly.
367-
// In particular we need to be careful that signalling NaN (sNaN) values
369+
// In particular we need to be careful that signaling NaN (sNaN) values
368370
// are not converted to quiet NaN (qNaN) values during compilation.
369371
// See issue #27193 for more information.
370372

371-
// signalling NaNs
373+
// TODO: this method for detecting 387 won't work if the compiler has been
374+
// built using GOARCH=386 GO386=387 and either the target is a different
375+
// architecture or the GO386=387 environment variable is not set when the
376+
// test is run.
377+
if runtime.GOARCH == "386" && os.Getenv("GO386") == "387" {
378+
t.Skip("signaling NaNs are not propagated on 387 (issue #27516)")
379+
}
380+
381+
// signaling NaNs
372382
{
373383
const nan = uint32(0x7f800001) // sNaN
374384
if x := math.Float32bits(math.Float32frombits(nan)); x != nan {

0 commit comments

Comments
 (0)