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]

copysign updates, part 3


Fixes the problem that Uros identified wrt the ieee subdirectory
implying -ffloat-store for this test, causeing it to fail sometimes.


r~


        * gcc.c-torture/execute/ieee/copysign1.c: Special case sizeof
        long double for intel double extended format.
        * gcc.c-torture/execute/ieee/copysign2.c: Likewise.

Index: gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c,v
retrieving revision 1.1
diff -u -p -d -r1.1 copysign1.c
--- gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c	28 Jan 2005 00:55:07 -0000	1.1
+++ gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c	31 Jan 2005 08:57:42 -0000
@@ -1,5 +1,22 @@
 #include <string.h>
 #include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff	sizeof(float)
+#define fpsizeof	sizeof(double)
+#define fpsizeofl	sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+   we've got a 10 byte type stuffed into some amount of padding.  And
+   the fact that -ffloat-store is going to stuff this value temporarily
+   into some bit of stack frame that we've no control over and can't zero.  */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+#  undef fpsizeofl
+#  define fpsizeofl	10
+# endif
+#endif
+
 
 #define TEST(TYPE, EXT)						\
 TYPE c##EXT (TYPE x, TYPE y)					\
@@ -25,12 +42,10 @@ void test##EXT (void)						\
 {								\
   int i, n = sizeof (T##EXT) / sizeof (T##EXT[0]);		\
   TYPE r;							\
-  /* Make sure to avoid comparing unused bits in the type.  */	\
-  memset (&r, 0, sizeof r);					\
   for (i = 0; i < n; ++i)					\
     {								\
       r = c##EXT (T##EXT[i].x, T##EXT[i].y);			\
-      if (memcmp (&r, &T##EXT[i].z, sizeof r) != 0)		\
+      if (memcmp (&r, &T##EXT[i].z, fpsizeof##EXT) != 0)	\
 	abort ();						\
     }								\
 }
Index: gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c,v
retrieving revision 1.1
diff -u -p -d -r1.1 copysign2.c
--- gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c	30 Jan 2005 17:55:12 -0000	1.1
+++ gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c	31 Jan 2005 08:57:42 -0000
@@ -1,5 +1,23 @@
 #include <string.h>
 #include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff	sizeof(float)
+#define fpsizeof	sizeof(double)
+#define fpsizeofl	sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+   we've got a 10 byte type stuffed into some amount of padding.  And
+   the fact that -ffloat-store is going to stuff this value temporarily
+   into some bit of stack frame that we've no control over and can't zero.  */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+#  undef fpsizeofl
+#  define fpsizeofl	10
+# endif
+#endif
+
+
 
 #define TEST(TYPE, EXT)						\
 static TYPE Y##EXT[] = {					\
@@ -13,8 +31,7 @@ static const TYPE Z##EXT[] = {					\
 void test##EXT (void)						\
 {								\
   TYPE r[8];							\
-  /* Make sure to avoid comparing unused bits in the type.  */	\
-  memset (r, 0, sizeof r);					\
+  int i;							\
   r[0] = __builtin_copysign##EXT (1.0, Y##EXT[0]);		\
   r[1] = __builtin_copysign##EXT (1.0, Y##EXT[1]);		\
   r[2] = __builtin_copysign##EXT (-1.0, Y##EXT[2]);		\
@@ -23,8 +40,9 @@ void test##EXT (void)						\
   r[5] = __builtin_copysign##EXT (-0.0, Y##EXT[5]);		\
   r[6] = __builtin_copysign##EXT (__builtin_inf##EXT (), Y##EXT[6]); \
   r[7] = __builtin_copysign##EXT (-__builtin_nan##EXT (""), Y##EXT[7]); \
-  if (memcmp (r, Z##EXT, sizeof r) != 0)			\
-    abort ();							\
+  for (i = 0; i < 8; ++i)					\
+    if (memcmp (r+i, Z##EXT+i, fpsizeof##EXT) != 0)		\
+      abort ();							\
 }
 
 TEST(float, f)


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