]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/88678 (Many gfortran.dg/ieee/ieee_X.f90 test cases fail starting with...
authorUros Bizjak <uros@gcc.gnu.org>
Sun, 3 Feb 2019 16:21:06 +0000 (17:21 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Sun, 3 Feb 2019 16:21:06 +0000 (17:21 +0100)
2019-02-03  Uroš Bizjak  <ubizjak@gmail.com>

PR libfortran/88678
Revert:
2016-11-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>

PR libfortran/78314
* config/fpu-glibc.h (support_fpu_trap): Use feenableexcept.

2019-02-03  Uroš Bizjak  <ubizjak@gmail.com>

PR libfortran/88678
* config/fpu-glibc.h (set_fpu_trap_exceptions): Clear stalled
exception flags before changing trap mode.  Optimize to call
feenableexcept and fedisableexcept only once.

From-SVN: r268493

libgfortran/ChangeLog
libgfortran/config/fpu-glibc.h

index b8b75e155f14f34e8cf80e6580340aae647377ab..219b1ffd89ad1ca210d9055018f240798dad79e0 100644 (file)
@@ -1,10 +1,26 @@
+2019-02-03  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR libfortran/88678
+       Revert:
+       2016-11-16  Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+       PR libfortran/78314
+       * config/fpu-glibc.h (support_fpu_trap): Use feenableexcept.
+
+2019-02-03  Uroš Bizjak  <ubizjak@gmail.com>
+
+       PR libfortran/88678
+       * config/fpu-glibc.h (set_fpu_trap_exceptions): Clear stalled
+       exception flags before changing trap mode.  Optimize to call
+       feenableexcept and fedisableexcept only once.
+
 2019-01-13  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libfortran/88776
        * io/list_read.c (namelist_read): Use nml_err_ret path on read error
        not based on stdin_unit.
        * io/open.c (newunit): Free format buffer if the unit specified is for
-       stdin, stdout, or stderr. 
+       stdin, stdout, or stderr.
 
 2018-12-06  Janne Blomqvist  <jb@gcc.gnu.org>
 
index a00a153be79c994f2006c1bd4a73dba843ba06f9..2f076be6587ea2c60dfb06d70028b42f296e109e 100644 (file)
@@ -39,48 +39,56 @@ _Static_assert (sizeof(fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
 
 void set_fpu_trap_exceptions (int trap, int notrap)
 {
+  int mode_set = 0, mode_clr = 0;
+
 #ifdef FE_INVALID
   if (trap & GFC_FPE_INVALID)
-    feenableexcept (FE_INVALID);
+    mode_set |= FE_INVALID;
   if (notrap & GFC_FPE_INVALID)
-    fedisableexcept (FE_INVALID);
+    mode_clr |= FE_INVALID;
 #endif
 
 /* Some glibc targets (like alpha) have FE_DENORMAL, but not many.  */
 #ifdef FE_DENORMAL
   if (trap & GFC_FPE_DENORMAL)
-    feenableexcept (FE_DENORMAL);
+    mode_set |= FE_DENORMAL;
   if (notrap & GFC_FPE_DENORMAL)
-    fedisableexcept (FE_DENORMAL);
+    mode_clr |= FE_DENORMAL;
 #endif
 
 #ifdef FE_DIVBYZERO
   if (trap & GFC_FPE_ZERO)
-    feenableexcept (FE_DIVBYZERO);
+    mode_set |= FE_DIVBYZERO;
   if (notrap & GFC_FPE_ZERO)
-    fedisableexcept (FE_DIVBYZERO);
+    mode_clr |= FE_DIVBYZERO;
 #endif
 
 #ifdef FE_OVERFLOW
   if (trap & GFC_FPE_OVERFLOW)
-    feenableexcept (FE_OVERFLOW);
+    mode_set |= FE_OVERFLOW;
   if (notrap & GFC_FPE_OVERFLOW)
-    fedisableexcept (FE_OVERFLOW);
+    mode_clr |= FE_OVERFLOW;
 #endif
 
 #ifdef FE_UNDERFLOW
   if (trap & GFC_FPE_UNDERFLOW)
-    feenableexcept (FE_UNDERFLOW);
+    mode_set |= FE_UNDERFLOW;
   if (notrap & GFC_FPE_UNDERFLOW)
-    fedisableexcept (FE_UNDERFLOW);
+    mode_clr |= FE_UNDERFLOW;
 #endif
 
 #ifdef FE_INEXACT
   if (trap & GFC_FPE_INEXACT)
-    feenableexcept (FE_INEXACT);
+    mode_set |= FE_INEXACT;
   if (notrap & GFC_FPE_INEXACT)
-    fedisableexcept (FE_INEXACT);
+    mode_clr |= FE_INEXACT;
 #endif
+
+  /* Clear stalled exception flags.  */
+  feclearexcept (FE_ALL_EXCEPT);
+
+  feenableexcept (mode_set);
+  fedisableexcept (mode_clr);
 }
 
 
@@ -121,41 +129,7 @@ get_fpu_trap_exceptions (void)
 int
 support_fpu_trap (int flag)
 {
-  int exceptions = 0;
-  int old;
-
-  if (!support_fpu_flag (flag))
-    return 0;
-
-#ifdef FE_INVALID
-  if (flag & GFC_FPE_INVALID) exceptions |= FE_INVALID;
-#endif
-
-#ifdef FE_DIVBYZERO
-  if (flag & GFC_FPE_ZERO) exceptions |= FE_DIVBYZERO;
-#endif
-
-#ifdef FE_OVERFLOW
-  if (flag & GFC_FPE_OVERFLOW) exceptions |= FE_OVERFLOW;
-#endif
-
-#ifdef FE_UNDERFLOW
-  if (flag & GFC_FPE_UNDERFLOW) exceptions |= FE_UNDERFLOW;
-#endif
-
-#ifdef FE_DENORMAL
-  if (flag & GFC_FPE_DENORMAL) exceptions |= FE_DENORMAL;
-#endif
-
-#ifdef FE_INEXACT
-  if (flag & GFC_FPE_INEXACT) exceptions |= FE_INEXACT;
-#endif
-
-  old = feenableexcept (exceptions);
-  if (old == -1)
-    return 0;
-  fedisableexcept (exceptions & ~old);
-  return 1;
+  return support_fpu_flag (flag);
 }