diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2020-05-01 19:20:57 +0200 |
---|---|---|
committer | Uros Bizjak <ubizjak@gmail.com> | 2020-05-01 19:20:57 +0200 |
commit | afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb (patch) | |
tree | 07fa9ec4b94921a6b90d301357f4eb4ef50a06a3 /libgfortran | |
parent | d730fd95eebaecad8e26f9e089c7df4630e94f1c (diff) | |
download | gcc-afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb.zip gcc-afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb.tar.gz gcc-afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb.tar.bz2 |
i386: Use generic division to generate INVALID and DIVZERO exceptions
Introduce math_force_eval to evaluate generic division to generate
INVALID and DIVZERO exceptions.
libgcc/ChangeLog:
* config/i386/sfp-exceptions.c (__math_force_eval): New define.
(__sfp_handle_exceptions): Use __math_force_eval to evaluete
generic division to generate INVALID and DIVZERO exceptions.
libatomic/ChangeLog:
* config/x86/fenv.c (__math_force_eval): New define.
(__atomic_feraiseexcept): Use __math_force_eval to evaluete
generic division to generate INVALID and DIVZERO exceptions.
libgfortran/ChangeLog:
* config/fpu-387.h (__math_force_eval): New define.
(local_feraiseexcept): Use __math_force_eval to evaluete
generic division to generate INVALID and DIVZERO exceptions.
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 6 | ||||
-rw-r--r-- | libgfortran/config/fpu-387.h | 19 |
2 files changed, 13 insertions, 12 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 8e3e087..eecfb90 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2020-05-01 Uroš Bizjak <ubizjak@gmail.com> + + * config/fpu-387.h (__math_force_eval): New define. + (local_feraiseexcept): Use __math_force_eval to evaluete + generic division to generate INVALID and DIVZERO exceptions. + 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: diff --git a/libgfortran/config/fpu-387.h b/libgfortran/config/fpu-387.h index 13be204..41b82bc 100644 --- a/libgfortran/config/fpu-387.h +++ b/libgfortran/config/fpu-387.h @@ -91,6 +91,11 @@ my_fenv_t; _Static_assert (sizeof(my_fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE, "GFC_FPE_STATE_BUFFER_SIZE is too small"); +#ifdef __SSE_MATH__ +# define __math_force_eval(x) __asm__ __volatile__ ("" : : "x" (x)); +#else +# define __math_force_eval(x) __asm__ __volatile__ ("" : : "f" (x)); +#endif /* Raise the supported floating-point exceptions from EXCEPTS. Other bits in EXCEPTS are ignored. Code originally borrowed from @@ -102,12 +107,7 @@ local_feraiseexcept (int excepts) if (excepts & _FPU_MASK_IM) { float f = 0.0f; -#ifdef __SSE_MATH__ - __asm__ __volatile__ ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f)); -#else - __asm__ __volatile__ ("fdiv\t{%y0, %0|%0, %y0}" : "+t" (f)); - /* No need for fwait, exception is triggered by emitted fstp. */ -#endif + __math_force_eval (f / f); } if (excepts & _FPU_MASK_DM) { @@ -120,12 +120,7 @@ local_feraiseexcept (int excepts) if (excepts & _FPU_MASK_ZM) { float f = 1.0f, g = 0.0f; -#ifdef __SSE_MATH__ - __asm__ __volatile__ ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g)); -#else - __asm__ __volatile__ ("fdivs\t%1" : "+t" (f) : "m" (g)); - /* No need for fwait, exception is triggered by emitted fstp. */ -#endif + __math_force_eval (f / g); } if (excepts & _FPU_MASK_OM) { |