]> Cypherpunks repositories - gostls13.git/commitdiff
math: test portable FMA even on system with hardware FMA
authorRuss Cox <rsc@golang.org>
Tue, 5 Nov 2019 01:36:21 +0000 (20:36 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 7 Nov 2019 14:53:38 +0000 (14:53 +0000)
This makes it a little less likely the portable FMA will be
broken without realizing it.

Change-Id: I7f7f4509b35160a9709f8b8a0e494c09ea6e410a
Reviewed-on: https://go-review.googlesource.com/c/go/+/205337
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/math/all_test.go

index e9621e6dc979958cf0ee113b5ce0e02339d3170a..1ac9d71a251780a797d3170f441ea171d69c529e 100644 (file)
@@ -3053,12 +3053,18 @@ func TestYn(t *testing.T) {
        }
 }
 
+var PortableFMA = FMA // hide call from compiler intrinsic; falls back to portable code
+
 func TestFMA(t *testing.T) {
        for _, c := range fmaC {
                got := FMA(c.x, c.y, c.z)
                if !alike(got, c.want) {
                        t.Errorf("FMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
                }
+               got = PortableFMA(c.x, c.y, c.z)
+               if !alike(got, c.want) {
+                       t.Errorf("PortableFMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
+               }
        }
 }