From 9de84e84f26b9bf2009f3ea7acc18059dacc04f9 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 7 Nov 2013 22:53:54 +0100 Subject: [PATCH] sfp-exceptions.c (__sfp_handle_exceptions): Rewrite FP_EX_INEXACT handling. * config/i386/sfp-exceptions.c (__sfp_handle_exceptions): Rewrite FP_EX_INEXACT handling. From-SVN: r204546 --- libgcc/ChangeLog | 1 + libgcc/config/i386/sfp-exceptions.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 8a644d745280..1b2a20b75bf6 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -4,6 +4,7 @@ FP_EX_DENORM. Store result to volatile location after SSE division to close interrupt window. Remove unneeded fwait after x87 division since interrupt window will be closed by emitted fstp. + Rewrite FP_EX_INEXACT handling. 2013-11-06 Joseph Myers diff --git a/libgcc/config/i386/sfp-exceptions.c b/libgcc/config/i386/sfp-exceptions.c index 6d449ec6093b..3504c4aedd17 100644 --- a/libgcc/config/i386/sfp-exceptions.c +++ b/libgcc/config/i386/sfp-exceptions.c @@ -48,7 +48,7 @@ __sfp_handle_exceptions (int _fex) { float f = 0.0f; #ifdef __x86_64__ - volatile float r; + volatile float r __attribute__ ((unused)); asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f)); r = f; /* Needed to trigger exception. */ #else @@ -68,7 +68,7 @@ __sfp_handle_exceptions (int _fex) { float f = 1.0f, g = 0.0f; #ifdef __x86_64__ - volatile float r; + volatile float r __attribute__ ((unused)); asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g)); r = f; /* Needed to trigger exception. */ #else @@ -94,11 +94,15 @@ __sfp_handle_exceptions (int _fex) } if (_fex & FP_EX_INEXACT) { - struct fenv temp; - asm volatile ("fnstenv\t%0" : "=m" (temp)); - temp.__status_word |= FP_EX_INEXACT; - asm volatile ("fldenv\t%0" : : "m" (temp)); - asm volatile ("fwait"); + float f = 1.0f, g = 3.0f; +#ifdef __x86_64__ + volatile float r __attribute__ ((unused)); + asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g)); + r = f; /* Needed to trigger exception. */ +#else + asm volatile ("fdivs\t%1" : "+t" (f) : "m" (g)); + /* No need for fwait, exception is triggered by emitted fstp. */ +#endif } }; #endif -- 2.39.5