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 /libatomic | |
parent | d730fd95eebaecad8e26f9e089c7df4630e94f1c (diff) | |
download | gcc-afb9b7108104a73e8ac7a9b8e6875870e5ca4bbb.tar.gz |
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 'libatomic')
-rw-r--r-- | libatomic/ChangeLog | 6 | ||||
-rw-r--r-- | libatomic/config/x86/fenv.c | 20 |
2 files changed, 14 insertions, 12 deletions
diff --git a/libatomic/ChangeLog b/libatomic/ChangeLog index 33527a7b456..48c115de49f 100644 --- a/libatomic/ChangeLog +++ b/libatomic/ChangeLog @@ -1,3 +1,9 @@ +2020-05-01 Uroš Bizjak <ubizjak@gmail.com> + + * 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. + 2020-04-19 Uroš Bizjak <ubizjak@gmail.com> * config/x86/fenv.c (__atomic_feraiseexcept) [__SSE_MATH__]: diff --git a/libatomic/config/x86/fenv.c b/libatomic/config/x86/fenv.c index d7b1bbe5ea1..d972a99f594 100644 --- a/libatomic/config/x86/fenv.c +++ b/libatomic/config/x86/fenv.c @@ -47,6 +47,12 @@ struct fenv unsigned short int __unused5; }; +#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. */ @@ -56,12 +62,7 @@ __atomic_feraiseexcept (int excepts) if (excepts & FE_INVALID) { 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 & FE_DENORM) { @@ -74,12 +75,7 @@ __atomic_feraiseexcept (int excepts) if (excepts & FE_DIVBYZERO) { 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 & FE_OVERFLOW) { |