diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2015-08-04 11:16:52 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2015-08-04 11:16:52 +0200 |
commit | 9f8aa64ac1bc6b282cb1c7aa362fb59dc6803250 (patch) | |
tree | 61138ddebd0e04f47cef8b477d8c57f77968a9ed /libgfortran | |
parent | 22a499884f31391a6ab02739861b2b343eebc94e (diff) | |
download | gcc-9f8aa64ac1bc6b282cb1c7aa362fb59dc6803250.zip gcc-9f8aa64ac1bc6b282cb1c7aa362fb59dc6803250.tar.gz gcc-9f8aa64ac1bc6b282cb1c7aa362fb59dc6803250.tar.bz2 |
fpu-387.h (get_fpu_trap_exceptions): Add temporary variable to improve generated code.
* config/fpu-387.h (get_fpu_trap_exceptions): Add temporary variable
to improve generated code.
From-SVN: r226549
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 5 | ||||
-rw-r--r-- | libgfortran/config/fpu-387.h | 39 |
2 files changed, 26 insertions, 18 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index e74bff6..744a913 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2015-08-04 Uros Bizjak <ubizjak@gmail.com> + + * config/fpu-387.h (get_fpu_trap_exceptions): Add temporary variable + to improve generated code. + 2015-08-04 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> PR fortran/64022 diff --git a/libgfortran/config/fpu-387.h b/libgfortran/config/fpu-387.h index 1d0711c..b6071af 100644 --- a/libgfortran/config/fpu-387.h +++ b/libgfortran/config/fpu-387.h @@ -215,12 +215,13 @@ set_fpu (void) int get_fpu_trap_exceptions (void) { - int res = 0; unsigned short cw; + int mask; + int res = 0; __asm__ __volatile__ ("fstcw\t%0" : "=m" (cw)); - cw &= _FPU_MASK_ALL; - + mask = cw; + if (has_sse()) { unsigned int cw_sse; @@ -228,15 +229,17 @@ get_fpu_trap_exceptions (void) __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse)); /* The SSE exception masks are shifted by 7 bits. */ - cw = cw | ((cw_sse >> 7) & _FPU_MASK_ALL); + mask |= (cw_sse >> 7); } - if (~cw & _FPU_MASK_IM) res |= GFC_FPE_INVALID; - if (~cw & _FPU_MASK_DM) res |= GFC_FPE_DENORMAL; - if (~cw & _FPU_MASK_ZM) res |= GFC_FPE_ZERO; - if (~cw & _FPU_MASK_OM) res |= GFC_FPE_OVERFLOW; - if (~cw & _FPU_MASK_UM) res |= GFC_FPE_UNDERFLOW; - if (~cw & _FPU_MASK_PM) res |= GFC_FPE_INEXACT; + mask = ~mask & _FPU_MASK_ALL; + + if (mask & _FPU_MASK_IM) res |= GFC_FPE_INVALID; + if (mask & _FPU_MASK_DM) res |= GFC_FPE_DENORMAL; + if (mask & _FPU_MASK_ZM) res |= GFC_FPE_ZERO; + if (mask & _FPU_MASK_OM) res |= GFC_FPE_OVERFLOW; + if (mask & _FPU_MASK_UM) res |= GFC_FPE_UNDERFLOW; + if (mask & _FPU_MASK_PM) res |= GFC_FPE_INEXACT; return res; } @@ -252,7 +255,7 @@ get_fpu_except_flags (void) { unsigned short cw; int excepts; - int result = 0; + int res = 0; __asm__ __volatile__ ("fnstsw\t%0" : "=am" (cw)); excepts = cw; @@ -267,14 +270,14 @@ get_fpu_except_flags (void) excepts &= _FPU_EX_ALL; - if (excepts & _FPU_MASK_IM) result |= GFC_FPE_INVALID; - if (excepts & _FPU_MASK_DM) result |= GFC_FPE_DENORMAL; - if (excepts & _FPU_MASK_ZM) result |= GFC_FPE_ZERO; - if (excepts & _FPU_MASK_OM) result |= GFC_FPE_OVERFLOW; - if (excepts & _FPU_MASK_UM) result |= GFC_FPE_UNDERFLOW; - if (excepts & _FPU_MASK_PM) result |= GFC_FPE_INEXACT; + if (excepts & _FPU_MASK_IM) res |= GFC_FPE_INVALID; + if (excepts & _FPU_MASK_DM) res |= GFC_FPE_DENORMAL; + if (excepts & _FPU_MASK_ZM) res |= GFC_FPE_ZERO; + if (excepts & _FPU_MASK_OM) res |= GFC_FPE_OVERFLOW; + if (excepts & _FPU_MASK_UM) res |= GFC_FPE_UNDERFLOW; + if (excepts & _FPU_MASK_PM) res |= GFC_FPE_INEXACT; - return result; + return res; } void |