summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 11:38:06 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 11:38:06 +0000
commitf70c02e6df2553e9d6180df2d701004113d1d68a (patch)
tree0cefadecdf1c0660b3b900372a1eae74e1944aa0 /gcc/testsuite/gcc.target/i386
parente4f4c49b3482f148af2ee403588b16cae2e8c093 (diff)
downloadgcc-f70c02e6df2553e9d6180df2d701004113d1d68a.tar.gz
2006-11-01 Richard Guenther <rguenther@suse.de>
* config/i386/i386.c (ix86_expand_rint): Fix issues with signed zeros. (ix86_expand_floorceildf_32): Likewise. (ix86_expand_floorceil): Likewise. (ix86_expand_trunc): Likewise. * testsuite/gcc.target/i386/fpprec-1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118373 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.target/i386')
-rw-r--r--gcc/testsuite/gcc.target/i386/fpprec-1.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/fpprec-1.c b/gcc/testsuite/gcc.target/i386/fpprec-1.c
new file mode 100644
index 00000000000..ff600b26198
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/fpprec-1.c
@@ -0,0 +1,90 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-math-errno -fno-trapping-math -msse2 -mfpmath=sse" } */
+
+#include "../../gcc.dg/i386-cpuid.h"
+
+extern void abort(void);
+extern int printf(const char *format, ...);
+
+double x[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023, /* +-DBL_MAX */
+ -0x1p-52, 0x1p-52, /* +-DBL_EPSILON */
+ /* nextafter/before 0.5, 1.0 and 1.5 */
+ 0x1.0000000000001p-1, 0x1.fffffffffffffp-2,
+ 0x1.0000000000001p+0, 0x1.fffffffffffffp-1,
+ 0x1.8000000000001p+0, 0x1.7ffffffffffffp+0,
+ -0.0, 0.0, -0.5, 0.5, -1.0, 1.0, -1.5, 1.5, -2.0, 2.0,
+ -2.5, 2.5 };
+#define NUM (sizeof(x)/sizeof(double))
+
+double expect_round[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
+ -0.0, 0.0,
+ 1.0, 0.0, 1.0, 1.0, 2.0, 1.0,
+ -0.0, 0.0, -1.0, 1.0, -1.0, 1.0, -2.0, 2.0, -2.0, 2.0,
+ -3.0, 3.0 };
+
+double expect_rint[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
+ -0.0, 0.0,
+ 1.0, 0.0, 1.0, 1.0, 2.0, 1.0,
+ -0.0, 0.0, -0.0, 0.0, -1.0, 1.0, -2.0, 2.0, -2.0, 2.0,
+ -2.0, 2.0 };
+
+double expect_floor[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
+ -1.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
+ -0.0, 0.0, -1.0, 0.0, -1.0, 1.0, -2.0, 1.0, -2.0, 2.0,
+ -3.0, 2.0 };
+
+double expect_ceil[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
+ -0.0, 1.0,
+ 1.0, 1.0, 2.0, 1.0, 2.0, 2.0,
+ -0.0, 0.0, -0.0, 1.0, -1.0, 1.0, -1.0, 2.0, -2.0, 2.0,
+ -2.0, 3.0 };
+
+double expect_trunc[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
+ -0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
+ -0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
+ -0.0, 0.0, -0.0, 0.0, -1.0, 1.0, -1.0, 1.0, -2.0, 2.0,
+ -2.0, 2.0 };
+
+
+#define CHECK(fn) \
+void check_ ## fn (void) \
+{ \
+ int i; \
+ for (i = 0; i < NUM; ++i) \
+ { \
+ double res = __builtin_ ## fn (x[i]); \
+ if (__builtin_memcmp (&res, &expect_ ## fn [i], sizeof(double)) != 0) \
+ printf( # fn " [%i]: %.18e %.18e\n", i, expect_ ## fn [i], res), abort (); \
+ } \
+}
+
+CHECK(round)
+CHECK(rint)
+CHECK(floor)
+CHECK(ceil)
+CHECK(trunc)
+
+int main()
+{
+ unsigned long cpu_facilities;
+
+ cpu_facilities = i386_cpuid ();
+
+ if ((cpu_facilities & bit_SSE2) != bit_SSE2)
+ /* If host has no SSE2 support, pass. */
+ return 0;
+
+ check_round ();
+ check_rint ();
+ check_floor ();
+ check_ceil ();
+ check_trunc ();
+ return 0;
+}