maint: update copyright
[gnulib.git] / tests / test-fma2.h
index b38bdbf..0a0a94c 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of fused multiply-add.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #define XE_RANGE 0
 #define YE_RANGE 0
 
-/* Define to 1 if you want to allow the behaviour of the glibc 2.11 fma()
-   implementation.  glibc bug #1..#16 refer to the test cases in
-   <http://sourceware.org/bugzilla/show_bug.cgi?id=13304>.  */
-#if __GLIBC__ >= 2 && 0
-# define FORGIVE_GLIBC_BUG 1
-#else
-# define FORGIVE_GLIBC_BUG 0
-#endif
-
 /* Define to 1 if you want to allow the behaviour of the 'double-double'
    implementation of 'long double' (seen on IRIX 6.5 and Linux/PowerPC).
    This floating-point type does not follow IEEE 754.  */
@@ -61,14 +52,14 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
       L_(1.0), - L_(1.0), L_(1.0), - L_(1.0),
       L_(1.0), - L_(1.0), L_(1.0), - L_(1.0)
     };
-  volatile DOUBLE x;
-  volatile DOUBLE y;
-  volatile DOUBLE z;
-  volatile DOUBLE result;
-  volatile DOUBLE expected;
 
   /* A product x * y that consists of two bits.  */
   {
+    volatile DOUBLE x;
+    volatile DOUBLE y;
+    volatile DOUBLE z;
+    volatile DOUBLE result;
+    volatile DOUBLE expected;
     int xs;
     int xe;
     int ys;
@@ -136,6 +127,11 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
   }
   /* A product x * y that consists of three bits.  */
   {
+    volatile DOUBLE x;
+    volatile DOUBLE y;
+    volatile DOUBLE z;
+    volatile DOUBLE result;
+    volatile DOUBLE expected;
     int i;
     int xs;
     int xe;
@@ -181,14 +177,10 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                               sign * (POW2 (xe + ye)
                                       + POW2 (xe + ye - i + 1));
                           else if (2 * i == MANT_BIT)
-                            {
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #7 */
-                                goto skip1;
-                              expected =
-                                sign * (POW2 (xe + ye)
-                                        + POW2 (xe + ye - i + 1)
-                                        + POW2 (xe + ye - MANT_BIT + 1));
-                            }
+                            expected =
+                              sign * (POW2 (xe + ye)
+                                      + POW2 (xe + ye - i + 1)
+                                      + POW2 (xe + ye - MANT_BIT + 1));
                           else
                             expected =
                               sign * (POW2 (xe + ye)
@@ -198,14 +190,10 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                       else if (xe + ye == ze + MANT_BIT)
                         {
                           if (2 * i >= MANT_BIT)
-                            {
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #8 */
-                                goto skip1;
-                              expected =
-                                sign * (POW2 (xe + ye)
-                                        + POW2 (xe + ye - i + 1)
-                                        + POW2 (xe + ye - MANT_BIT + 1));
-                            }
+                            expected =
+                              sign * (POW2 (xe + ye)
+                                      + POW2 (xe + ye - i + 1)
+                                      + POW2 (xe + ye - MANT_BIT + 1));
                           else if (2 * i == MANT_BIT - 1)
                             /* round-to-even rounds up */
                             expected =
@@ -219,16 +207,11 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                                       + POW2 (xe + ye - 2 * i));
                         }
                       else if (xe + ye > ze - MANT_BIT + 2 * i)
-                        {
-                          if (2 * i == MANT_BIT)
-                            if (FORGIVE_GLIBC_BUG) /* glibc bug #9 */
-                              goto skip1;
-                          expected =
-                            sign * (POW2 (ze)
-                                    + POW2 (xe + ye)
-                                    + POW2 (xe + ye - i + 1)
-                                    + POW2 (xe + ye - 2 * i));
-                        }
+                        expected =
+                          sign * (POW2 (ze)
+                                  + POW2 (xe + ye)
+                                  + POW2 (xe + ye - i + 1)
+                                  + POW2 (xe + ye - 2 * i));
                       else if (xe + ye >= ze - MANT_BIT + i)
                         expected =
                           sign * (POW2 (ze)
@@ -236,9 +219,6 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                                   + POW2 (xe + ye - i + 1));
                       else if (xe + ye == ze - MANT_BIT + i - 1)
                         {
-                          if (2 * i >= MANT_BIT)
-                            if (FORGIVE_GLIBC_BUG) /* glibc bug #3, #10 */
-                              goto skip1;
                           if (i == 1)
                             expected =
                               sign * (POW2 (ze) + POW2 (ze - MANT_BIT + 1));
@@ -256,12 +236,8 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                       else if (xe + ye == ze - MANT_BIT - 1)
                         {
                           if (i == 1)
-                            {
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #1 */
-                                goto skip1;
-                              expected =
-                                sign * (POW2 (ze) + POW2 (ze - MANT_BIT + 1));
-                            }
+                            expected =
+                              sign * (POW2 (ze) + POW2 (ze - MANT_BIT + 1));
                           else
                             expected = z;
                         }
@@ -299,9 +275,6 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                         if (xe + ye == ze)
                           {
                             /* maximal extinction */
-                            if (2 * i >= MANT_BIT)
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #12 */
-                                goto skip2;
                             expected =
                               sign * (POW2 (xe + ye - i + 1)
                                       + POW2 (xe + ye - 2 * i));
@@ -314,15 +287,10 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                                 sign * (- POW2 (xe + ye)
                                         + POW2 (xe + ye - i + 1));
                             else
-                              {
-                                if (2 * i == MANT_BIT)
-                                  if (FORGIVE_GLIBC_BUG) /* glibc bug #13 */
-                                    goto skip2;
-                                expected =
-                                  sign * (- POW2 (xe + ye)
-                                          + POW2 (xe + ye - i + 1)
-                                          + POW2 (xe + ye - 2 * i));
-                              }
+                              expected =
+                                sign * (- POW2 (xe + ye)
+                                        + POW2 (xe + ye - i + 1)
+                                        + POW2 (xe + ye - 2 * i));
                           }
                         else if (xe + ye > ze + MANT_BIT)
                           {
@@ -355,43 +323,29 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                                         + POW2 (xe + ye - 2 * i));
                           }
                         else if (xe + ye >= ze - MANT_BIT + 2 * i)
-                          {
-                            if (2 * i == MANT_BIT)
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #11 */
-                                goto skip2;
-                            expected =
-                              sign * (- POW2 (ze)
-                                      + POW2 (xe + ye)
-                                      + POW2 (xe + ye - i + 1)
-                                      + POW2 (xe + ye - 2 * i));
-                          }
+                          expected =
+                            sign * (- POW2 (ze)
+                                    + POW2 (xe + ye)
+                                    + POW2 (xe + ye - i + 1)
+                                    + POW2 (xe + ye - 2 * i));
                         else if (xe + ye >= ze - MANT_BIT + i - 1)
                           expected =
                             sign * (- POW2 (ze)
                                     + POW2 (xe + ye)
                                     + POW2 (xe + ye - i + 1));
                         else if (xe + ye == ze - MANT_BIT + i - 2)
-                          {
-                            if (2 * i >= MANT_BIT)
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #4, #14 */
-                                goto skip2;
-                            expected =
-                              sign * (- POW2 (ze)
-                                      + POW2 (xe + ye)
-                                      + POW2 (ze - MANT_BIT));
-                          }
+                          expected =
+                            sign * (- POW2 (ze)
+                                    + POW2 (xe + ye)
+                                    + POW2 (ze - MANT_BIT));
                         else if (xe + ye >= ze - MANT_BIT)
                           expected =
                             sign * (- POW2 (ze)
                                     + POW2 (xe + ye));
                         else if (xe + ye == ze - MANT_BIT - 1)
-                          {
-                            if (FORGIVE_GLIBC_BUG) /* glibc bug #2 */
-                              goto skip2;
-                            expected =
-                              sign * (- POW2 (ze)
-                                      + POW2 (ze - MANT_BIT));
-                          }
+                          expected =
+                            sign * (- POW2 (ze)
+                                    + POW2 (ze - MANT_BIT));
                         else
                           expected = z;
                         ASSERT (result == expected);
@@ -412,6 +366,11 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
   /* A product x * y that consists of one segment of bits (or, if you prefer,
      two bits, one with positive weight and one with negative weight).  */
   {
+    volatile DOUBLE x;
+    volatile DOUBLE y;
+    volatile DOUBLE z;
+    volatile DOUBLE result;
+    volatile DOUBLE expected;
     int i;
     int xs;
     int xe;
@@ -510,9 +469,6 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                         if (xe + ye == ze)
                           {
                             /* maximal extinction */
-                            if (2 * i > MANT_BIT)
-                              if (FORGIVE_GLIBC_BUG) /* glibc bug #16 */
-                                goto skip4;
                             expected = sign * - POW2 (xe + ye - 2 * i);
                           }
                         else if (xe + ye > ze + MANT_BIT + 1)
@@ -520,13 +476,9 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                             if (2 * i > MANT_BIT + 1)
                               expected = sign * POW2 (xe + ye);
                             else if (2 * i == MANT_BIT + 1)
-                              {
-                                if (FORGIVE_GLIBC_BUG) /* glibc bug #6 */
-                                  goto skip4;
-                                expected =
-                                  sign * (POW2 (xe + ye)
-                                          - POW2 (xe + ye - MANT_BIT));
-                              }
+                              expected =
+                                sign * (POW2 (xe + ye)
+                                        - POW2 (xe + ye - MANT_BIT));
                             else
                               expected =
                                 sign * (POW2 (xe + ye)
@@ -535,13 +487,9 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                         else if (xe + ye == ze + MANT_BIT + 1)
                           {
                             if (2 * i > MANT_BIT)
-                              {
-                                if (FORGIVE_GLIBC_BUG) /* glibc bug #15 */
-                                  goto skip4;
-                                expected =
-                                  sign * (POW2 (xe + ye)
-                                          - POW2 (xe + ye - MANT_BIT));
-                              }
+                              expected =
+                                sign * (POW2 (xe + ye)
+                                        - POW2 (xe + ye - MANT_BIT));
                             else if (2 * i == MANT_BIT)
                               expected =
                                 sign * (POW2 (xe + ye)
@@ -583,14 +531,8 @@ test_function (DOUBLE (*my_fma) (DOUBLE, DOUBLE, DOUBLE))
                             sign * (- POW2 (ze)
                                     + POW2 (xe + ye)
                                     - POW2 (xe + ye - 2 * i));
-                        else if (xe + ye > ze - MANT_BIT)
+                        else if (xe + ye >= ze - MANT_BIT)
                           expected = sign * (- POW2 (ze) + POW2 (xe + ye));
-                        else if (xe + ye == ze - MANT_BIT)
-                          {
-                            if (FORGIVE_GLIBC_BUG) /* glibc bug #5 */
-                              goto skip4;
-                            expected = sign * (- POW2 (ze) + POW2 (xe + ye));
-                          }
                         else
                           expected = z;
                         ASSERT (result == expected);