[BZ #3268] Additional fma tests

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[BZ #3268] Additional fma tests

Steven Munroe
Previous soft-fp work exposed a general lack of correct Fused Multiply Add (fma) implemetations for platforms that don't implement fma in hardware (soft-fp or hard-fp that doesn't implement fma).

This patch updates libm-test.inc to actually test for the full percision of fma. IEEE-754r states:

2 Definitions

"fused multiply-add: The operation fma(x,y,z) computes (x � )+z as if with unbounded range and precision, rounding only once to the destination format; see subclause 5.1. "

5.1 Arithmetic

"The operation fma(x,y,z) computes (x�)+z as if with unbounded range and precision, rounding only once to the destination format. No underflow, overflow, or inexact exception (subclause 7) can arise due to the multiply, but only due to the add; and so fused multiply-add differs from a multiply operation followed by an add operation."

This patch has been updated and verified on powerpc32 with todays CVS.



2007-04-03  Steven Munroe  <[hidden email]>

        [BZ #3268]
        * math/libm-test.inc (fma_test): New tests.

diff -urN libc25-cvstip-20070320/math/libm-test.inc libc25/math/libm-test.inc
--- libc25-cvstip-20070320/math/libm-test.inc 2007-03-15 15:10:16.000000000 -0500
+++ libc25/math/libm-test.inc 2007-03-30 15:30:26.000000000 -0500
@@ -2766,6 +2766,12 @@
 
   TEST_fff_f (fma, 1.25L, 0.75L, 0.0625L, 1.0L);
 
+  TEST_fff_f (fma, 8388609.0L, 8388609.0L, -70368752566272.0L, 8388609.0L);
+
+#ifdef TEST_DOUBLE
+  TEST_fff_f (fma, 0x1.0000000000001p+52, 0x1.0000000000001p+52, -0x1.0000000000001p+104, 0x1.0000000000001p+52);
+#endif
+
   END (fma);
 }