]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sfp-exceptions.c (__sfp_handle_exceptions): Handle FP_EX_DENORM.
authorUros Bizjak <ubizjak@gmail.com>
Thu, 7 Nov 2013 19:45:28 +0000 (20:45 +0100)
committerUros Bizjak <uros@gcc.gnu.org>
Thu, 7 Nov 2013 19:45:28 +0000 (20:45 +0100)
* config/i386/sfp-exceptions.c (__sfp_handle_exceptions): Handle
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.

From-SVN: r204540

libgcc/ChangeLog
libgcc/config/i386/sfp-exceptions.c

index 4da11a0406ba3fb5d152003f3f835cc50898f467..8a644d745280b3a905650b75e2a01d00895af547 100644 (file)
@@ -1,3 +1,10 @@
+2013-11-07  Uros Bizjak  <ubizjak@gmail.com>
+
+       * config/i386/sfp-exceptions.c (__sfp_handle_exceptions): Handle
+       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.
+
 2013-11-06  Joseph Myers  <joseph@codesourcery.com>
 
        * soft-fp/README: Update.
index fbaaab22f5080b1edb998331eeef6f7b47ad117e..6d449ec6093b9093057fb896592169e43318d2ec 100644 (file)
@@ -48,20 +48,32 @@ __sfp_handle_exceptions (int _fex)
     {
       float f = 0.0f;
 #ifdef __x86_64__
+      volatile float r;
       asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f));
+      r = f; /* Needed to trigger exception.   */
 #else
       asm volatile ("fdiv\t{%y0, %0|%0, %y0}" : "+t" (f));
-      asm volatile ("fwait");
+      /* No need for fwait, exception is triggered by emitted fstp.  */
 #endif
     }
+  if (_fex & FP_EX_DENORM)
+    {
+      struct fenv temp;
+      asm volatile ("fnstenv\t%0" : "=m" (temp));
+      temp.__status_word |= FP_EX_DENORM;
+      asm volatile ("fldenv\t%0" : : "m" (temp));
+      asm volatile ("fwait");
+    }
   if (_fex & FP_EX_DIVZERO)
     {
       float f = 1.0f, g = 0.0f;
 #ifdef __x86_64__
+      volatile float r;
       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));
-      asm volatile ("fwait");
+      /* No need for fwait, exception is triggered by emitted fstp.  */
 #endif
     }
   if (_fex & FP_EX_OVERFLOW)