aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-09-18 13:00:21 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2014-09-18 13:00:21 +0100
commite770bfd997bb5803b88ca4081bdbca3e250fc92e (patch)
treef8eda81754a6c8acd78502eec0b4a7e3ff0fcef7 /gcc
parentb5a260238027e86912c39df2147e345ca8a6ed26 (diff)
downloadgcc-e770bfd997bb5803b88ca4081bdbca3e250fc92e.zip
gcc-e770bfd997bb5803b88ca4081bdbca3e250fc92e.tar.gz
gcc-e770bfd997bb5803b88ca4081bdbca3e250fc92e.tar.bz2
Fix i386 FP_TRAPPING_EXCEPTIONS.
The i386 sfp-machine.h defines FP_TRAPPING_EXCEPTIONS in a way that is always wrong: it treats a set bit as indicating the exception is trapping, when actually a set bit (both for 387 and SSE floating point) indicates it is masked, and a clear bit indicates it is trapping. This patch fixes this bug. Bootstrapped with no regressions on x86_64-unknown-linux-gnu. libgcc: * config/i386/sfp-machine.h (FP_TRAPPING_EXCEPTIONS): Treat clear bits not set bits as indicating trapping exceptions. gcc/testsuite: * gcc.dg/torture/float128-exact-underflow.c: New test. From-SVN: r215347
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/torture/float128-exact-underflow.c41
2 files changed, 45 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 60a402f..41e5d2b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-09-18 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/torture/float128-exact-underflow.c: New test.
+
2014-09-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/61745
diff --git a/gcc/testsuite/gcc.dg/torture/float128-exact-underflow.c b/gcc/testsuite/gcc.dg/torture/float128-exact-underflow.c
new file mode 100644
index 0000000..8d448cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float128-exact-underflow.c
@@ -0,0 +1,41 @@
+/* Test that exact underflow in __float128 signals the underflow
+ exception if trapping is enabled, but does not raise the flag
+ otherwise. */
+
+/* { dg-do run { target i?86-*-*gnu* x86_64-*-*gnu* ia64-*-*gnu* } } */
+/* { dg-options "-D_GNU_SOURCE" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdlib.h>
+
+volatile sig_atomic_t caught_sigfpe;
+sigjmp_buf buf;
+
+static void
+handle_sigfpe (int sig)
+{
+ caught_sigfpe = 1;
+ siglongjmp (buf, 1);
+}
+
+int
+main (void)
+{
+ volatile __float128 a = 0x1p-16382q, b = 0x1p-2q;
+ volatile __float128 r;
+ r = a * b;
+ if (fetestexcept (FE_UNDERFLOW))
+ abort ();
+ if (r != 0x1p-16384q)
+ abort ();
+ feenableexcept (FE_UNDERFLOW);
+ signal (SIGFPE, handle_sigfpe);
+ if (sigsetjmp (buf, 1) == 0)
+ r = a * b;
+ if (!caught_sigfpe)
+ abort ();
+ exit (0);
+}