From e8f01d591f9be2653bfb13c0214c4c96b64aa028 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 4 Nov 2019 20:36:21 -0500 Subject: [PATCH] math: test portable FMA even on system with hardware FMA 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 Reviewed-by: Brad Fitzpatrick Reviewed-by: Keith Randall --- src/math/all_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/math/all_test.go b/src/math/all_test.go index e9621e6dc9..1ac9d71a25 100644 --- a/src/math/all_test.go +++ b/src/math/all_test.go @@ -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) + } } } -- 2.48.1