* gcc.c-torture/execute/ieee/mzero3.c: New test.
authorHans-Peter Nilsson <hp@bitrange.com>
Fri, 20 Sep 2002 03:04:15 +0000 (03:04 +0000)
committerHans-Peter Nilsson <hp@gcc.gnu.org>
Fri, 20 Sep 2002 03:04:15 +0000 (03:04 +0000)
From-SVN: r57331

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/ieee/mzero3.c [new file with mode: 0644]

index 436926d5b58b8bf0177d2ede45767c664cf6b347..970342e558b77051807abacf45851a014f023d95 100644 (file)
@@ -1,5 +1,7 @@
 2002-09-20  Hans-Peter Nilsson  <hp@bitrange.com>
 
+       * gcc.c-torture/execute/ieee/mzero3.c: New test.
+
        * lib/scanasm.exp (scan-assembler-dem, scan-assembler-dem-not):
        Adjust for c++filt moved to binutils.  Remove spurious duplicate
        setting of cxxfilt.
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/mzero3.c b/gcc/testsuite/gcc.c-torture/execute/ieee/mzero3.c
new file mode 100644 (file)
index 0000000..fdfb8a1
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002  Free Software Foundation.
+   by Hans-Peter Nilsson  <hp@bitrange.com>, derived from mzero2.c
+
+   In the MMIX port, negdf2 was bogusly expanding -x into 0 - x.  */
+
+double nzerod = -0.0;
+float nzerof = -0.0;
+double zerod = 0.0;
+float zerof = 0.0;
+
+void expectd (double, double);
+void expectf (float, float);
+double negd (double);
+float negf (float);
+
+main ()
+{
+  expectd (negd (zerod), nzerod);
+  expectf (negf (zerof), nzerof);
+  expectd (negd (nzerod), zerod);
+  expectf (negf (nzerof), zerof);
+  exit (0);
+}
+
+void
+expectd (double value, double expected)
+{
+  if (value != expected
+      || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)
+    abort ();
+}
+
+void
+expectf (float value, float expected)
+{
+  if (value != expected
+      || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)
+    abort ();
+}
+
+double
+negd (double v)
+{
+  return -v;
+}
+
+float
+negf (float v)
+{
+  return -v;
+}