From 0833715674fd74fc8d495487e6eea4ede239884a Mon Sep 17 00:00:00 2001 From: thesyncim Date: Sat, 31 Oct 2026 19:52:18 +0000 Subject: [PATCH] testdata: compare NaN results with the same machine's scalar build abs_sqrt.txt, activation_temp.txt and invariant_call.txt compare both builds with testmain/output, which was recorded on amd64. A NaN that an operation creates (the square root of a negative number, 0 times infinity) has the sign bit set on amd64 and clear on arm64, so on arm64 the scalar program itself does not match the recording and the scripts fail before the simd build runs. The recording is now compared only on amd64. On every target the simd build is compared with the scalar build of the same machine, which is the property these scripts check: the rewrite produces the same bits the scalar loop does there. --- testdata/abs_sqrt.txt | 11 +++++++++-- testdata/activation_temp.txt | 11 +++++++++-- testdata/invariant_call.txt | 11 +++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/testdata/abs_sqrt.txt b/testdata/abs_sqrt.txt index fa05a04..d6368e2 100644 --- a/testdata/abs_sqrt.txt +++ b/testdata/abs_sqrt.txt @@ -4,9 +4,15 @@ # float32. The inputs include -0, infinities, NaNs, and negative numbers, and the # output is compared bit for bit. +# testmain/output was recorded on amd64: a NaN that an operation creates (the square +# root of a negative number, 0 times infinity) has the sign bit set there and clear +# on arm64, so the recording is compared only on amd64, and on every target the +# simd build is compared with the scalar build of the same machine. + # The scalar program is the reference behavior. exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cp stdout scalar.out cp ops.go ops.go.orig loopvec -split . @@ -18,7 +24,8 @@ cmp ops.go ops.go.guarded # The simd build must behave identically. env GOEXPERIMENT=simd exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cmp stdout scalar.out -- go.mod -- module example.com/test diff --git a/testdata/activation_temp.txt b/testdata/activation_temp.txt index dc2f51b..5526f8d 100644 --- a/testdata/activation_temp.txt +++ b/testdata/activation_temp.txt @@ -4,8 +4,14 @@ # if/else if, then use it. Results must match the scalar loop bit for bit, NaN, # infinities and signed zeros included. +# testmain/output was recorded on amd64: a NaN that an operation creates (the square +# root of a negative number, 0 times infinity) has the sign bit set there and clear +# on arm64, so the recording is compared only on amd64, and on every target the +# simd build is compared with the scalar build of the same machine. + exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cp stdout scalar.out cp ops.go ops.go.orig loopvec -split . @@ -16,7 +22,8 @@ cmp ops.go ops.go.guarded env GOEXPERIMENT=simd exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cmp stdout scalar.out -- go.mod -- module example.com/test diff --git a/testdata/invariant_call.txt b/testdata/invariant_call.txt index 903e7ab..3f1fcf5 100644 --- a/testdata/invariant_call.txt +++ b/testdata/invariant_call.txt @@ -3,8 +3,14 @@ # the call is evaluated once before the loop. The results must match the scalar loop # bit for bit, which is the only way to compare NaN and negative zero. +# testmain/output was recorded on amd64: a NaN that an operation creates (the square +# root of a negative number, 0 times infinity) has the sign bit set there and clear +# on arm64, so the recording is compared only on amd64, and on every target the +# simd build is compared with the scalar build of the same machine. + exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cp stdout scalar.out cp ops.go ops.go.orig loopvec -split . @@ -15,7 +21,8 @@ cmp ops.go ops.go.guarded env GOEXPERIMENT=simd exec go run ./testmain -cmp stdout testmain/output +[GOARCH:amd64] cmp stdout testmain/output +cmp stdout scalar.out -- go.mod -- module example.com/test