This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH TESTSUITE]: Fix gcc.dg/torture/builtin-math-6.c


On Mon, 15 Jun 2009, Janis Johnson wrote:

> > 2009-06-08  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
> >
> > 	* gcc.dg/torture/builtin-math-6.c: Robustify and fix clog case.
>
> OK, but please add a comment to any tests that now fail with mpc-0.6
> because of this change.
> Janis

Done, here's what I installed.

		Thanks,
		--Kaveh


2009-06-16  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.dg/torture/builtin-math-6.c: Robustify and fix clog cases.

diff -rup orig/egcc-SVN20090616/gcc/testsuite/gcc.dg/torture/builtin-math-6.c egcc-SVN20090616/gcc/testsuite/gcc.dg/torture/builtin-math-6.c
--- orig/egcc-SVN20090616/gcc/testsuite/gcc.dg/torture/builtin-math-6.c	2009-05-16 02:01:01.000000000 +0200
+++ egcc-SVN20090616/gcc/testsuite/gcc.dg/torture/builtin-math-6.c	2009-06-16 06:23:00.000000000 +0200
@@ -11,57 +11,73 @@
 /* All references to link_error should go away at compile-time.  */
 extern void link_error(int);

-/* Return TRUE if the sign of X != sign of Y.  This is important when
-   comparing signed zeros.  */
+/* Return TRUE if the signs of floating point values X and Y are not
+   equal.  This is important when comparing signed zeros.  */
 #define CKSGN_F(X,Y) \
-  (__builtin_copysignf(1.0F,(X)) != __builtin_copysignf(1.0F,(Y)))
+  (__builtin_copysignf(1,(X)) != __builtin_copysignf(1,(Y)))
 #define CKSGN(X,Y) \
-  (__builtin_copysign(1.0,(X)) != __builtin_copysign(1.0,(Y)))
+  (__builtin_copysign(1,(X)) != __builtin_copysign(1,(Y)))
 #define CKSGN_L(X,Y) \
-  (__builtin_copysignl(1.0L,(X)) != __builtin_copysignl(1.0L,(Y)))
+  (__builtin_copysignl(1,(X)) != __builtin_copysignl(1,(Y)))
+
+/* Return TRUE if signs of the real parts, and the signs of the
+   imaginary parts, of X and Y are not equal.  */
+#define COMPLEX_CKSGN_F(X,Y) \
+  (CKSGN_F(__real__ (X), __real__ (Y)) || CKSGN_F (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN(X,Y) \
+  (CKSGN(__real__ (X), __real__ (Y)) || CKSGN (__imag__ (X), __imag__ (Y)))
+#define COMPLEX_CKSGN_L(X,Y) \
+  (CKSGN_L(__real__ (X), __real__ (Y)) || CKSGN_L (__imag__ (X), __imag__ (Y)))

 /* For complex numbers, test that FUNC(ARG) == (RES).  */
 #define TESTIT_COMPLEX(FUNC, ARG, RES) do { \
   if (__builtin_##FUNC##f(ARG) != (RES) \
-    || CKSGN_F(__real__ __builtin_##FUNC##f(ARG), __real__ (RES)) \
-    || CKSGN_F(__imag__ __builtin_##FUNC##f(ARG), __imag__ (RES))) \
+    || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
       link_error(__LINE__); \
   if (__builtin_##FUNC(ARG) != (RES) \
-    || CKSGN(__real__ __builtin_##FUNC(ARG), __real__ (RES)) \
-    || CKSGN(__imag__ __builtin_##FUNC(ARG), __imag__ (RES))) \
+    || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
       link_error(__LINE__); \
   if (__builtin_##FUNC##l(ARG) != (RES) \
-    || CKSGN_L(__real__ __builtin_##FUNC##l(ARG), __real__ (RES)) \
-    || CKSGN_L(__imag__ __builtin_##FUNC##l(ARG), __imag__ (RES))) \
+    || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG), (RES))) \
       link_error(__LINE__); \
   } while (0)

+/* Return TRUE if X differs from EXPECTED by more than 1%.  If
+   EXPECTED is zero, then any difference may return TRUE.  We don't
+   worry about signed zeros.  */
+#define DIFF1PCT_F(X,EXPECTED) \
+  (__builtin_fabsf((X)-(EXPECTED)) * 100 > __builtin_fabsf(EXPECTED))
+#define DIFF1PCT(X,EXPECTED) \
+  (__builtin_fabs((X)-(EXPECTED)) * 100 > __builtin_fabs(EXPECTED))
+#define DIFF1PCT_L(X,EXPECTED) \
+  (__builtin_fabsl((X)-(EXPECTED)) * 100 > __builtin_fabsl(EXPECTED))
+
+/* Return TRUE if complex value X differs from EXPECTED by more than
+   1% in either the real or imaginary parts.  */
+#define COMPLEX_DIFF1PCT_F(X,EXPECTED) \
+  (DIFF1PCT_F(__real__ (X), __real__ (EXPECTED)) \
+   || DIFF1PCT_F(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT(X,EXPECTED) \
+  (DIFF1PCT(__real__ (X), __real__ (EXPECTED)) \
+   || DIFF1PCT(__imag__ (X), __imag__ (EXPECTED)))
+#define COMPLEX_DIFF1PCT_L(X,EXPECTED) \
+  (DIFF1PCT_L(__real__ (X), __real__ (EXPECTED)) \
+   || DIFF1PCT_L(__imag__ (X), __imag__ (EXPECTED)))
+
 /* Range test, for complex numbers check that FUNC(ARG) is within 1%
    of RES.  This is NOT a test for accuracy to the last-bit, we're
    merely checking that we get relatively sane results.  I.e. the GCC
    builtin is hooked up to the correct MPC function call.  We first
    check the magnitude and then the sign.  */
 #define TESTIT_COMPLEX_R(FUNC, ARG, RES) do { \
-  if (__builtin_fabsf(__real__ __builtin_##FUNC##f(ARG)) < __builtin_fabsf(__real__ (RES)) * 0.99F \
-      || __builtin_fabsf(__real__ __builtin_##FUNC##f(ARG)) > __builtin_fabsf(__real__ (RES)) * 1.01F \
-      || __builtin_fabsf(__imag__ __builtin_##FUNC##f(ARG)) < __builtin_fabsf(__imag__ (RES)) * 0.99F \
-      || __builtin_fabsf(__imag__ __builtin_##FUNC##f(ARG)) > __builtin_fabsf(__imag__ (RES)) * 1.01F \
-      || CKSGN_F(__real__ __builtin_##FUNC##f(ARG), __real__ (RES)) \
-      || CKSGN_F(__imag__ __builtin_##FUNC##f(ARG), __imag__ (RES))) \
+  if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG), (RES)) \
+      || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG), (RES))) \
     link_error(__LINE__); \
-  if (__builtin_fabs(__real__ __builtin_##FUNC(ARG)) < __builtin_fabs(__real__ (RES)) * 0.99F \
-      || __builtin_fabs(__real__ __builtin_##FUNC(ARG)) > __builtin_fabs(__real__ (RES)) * 1.01F \
-      || __builtin_fabs(__imag__ __builtin_##FUNC(ARG)) < __builtin_fabs(__imag__ (RES)) * 0.99F \
-      || __builtin_fabs(__imag__ __builtin_##FUNC(ARG)) > __builtin_fabs(__imag__ (RES)) * 1.01F \
-      || CKSGN(__real__ __builtin_##FUNC(ARG), __real__ (RES)) \
-      || CKSGN(__imag__ __builtin_##FUNC(ARG), __imag__ (RES))) \
+  if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+      || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
     link_error(__LINE__); \
-  if (__builtin_fabsl(__real__ __builtin_##FUNC##l(ARG)) < __builtin_fabsl(__real__ (RES)) * 0.99F \
-      || __builtin_fabsl(__real__ __builtin_##FUNC##l(ARG)) > __builtin_fabsl(__real__ (RES)) * 1.01F \
-      || __builtin_fabsl(__imag__ __builtin_##FUNC##l(ARG)) < __builtin_fabsl(__imag__ (RES)) * 0.99F \
-      || __builtin_fabsl(__imag__ __builtin_##FUNC##l(ARG)) > __builtin_fabsl(__imag__ (RES)) * 1.01F \
-      || CKSGN_L(__real__ __builtin_##FUNC##l(ARG), __real__ (RES)) \
-      || CKSGN_L(__imag__ __builtin_##FUNC##l(ARG), __imag__ (RES))) \
+  if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG), (RES)) \
+      || COMPLEX_CKSGN(__builtin_##FUNC(ARG), (RES))) \
     link_error(__LINE__); \
   } while (0)

@@ -129,8 +145,8 @@ int main (void)

   TESTIT_COMPLEX (clog, 1.0F, 0.0F);
   TESTIT_COMPLEX_R (clog, -1.0F, 3.141593FI);
-  TESTIT_COMPLEX (clog, __builtin_conjf(1.0F), 0.0F);
-  TESTIT_COMPLEX_R (clog, __builtin_conjf(-1.0F), 3.141593FI);
+  TESTIT_COMPLEX (clog, __builtin_conjf(1.0F), __builtin_conjf(0.0F)); /* Fails with mpc-0.6.  */
+  TESTIT_COMPLEX_R (clog, __builtin_conjf(-1.0F), __builtin_conjf(3.141593FI)); /* Fails with mpc-0.6.  */

   TESTIT_COMPLEX_R (clog, 3.45678F + 2.34567FI, 1.429713F + 0.596199FI);
   TESTIT_COMPLEX_R (clog, 3.45678F - 2.34567FI, 1.429713F - 0.596199FI);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]