From: Uros Bizjak Date: Tue, 4 Aug 2015 09:16:52 +0000 (+0200) Subject: fpu-387.h (get_fpu_trap_exceptions): Add temporary variable to improve generated... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f8aa64ac1bc6b282cb1c7aa362fb59dc6803250;p=gcc.git 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 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index e74bff61dac..744a913c61f 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2015-08-04 Uros Bizjak + + * config/fpu-387.h (get_fpu_trap_exceptions): Add temporary variable + to improve generated code. + 2015-08-04 Francois-Xavier Coudert PR fortran/64022 diff --git a/libgfortran/config/fpu-387.h b/libgfortran/config/fpu-387.h index 1d0711ce3b1..b6071afa65a 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