Commit 9de84e84 by Uros Bizjak Committed by Uros Bizjak

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
parent 722516b8
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
FP_EX_DENORM. Store result to volatile location after SSE division FP_EX_DENORM. Store result to volatile location after SSE division
to close interrupt window. Remove unneeded fwait after x87 to close interrupt window. Remove unneeded fwait after x87
division since interrupt window will be closed by emitted fstp. division since interrupt window will be closed by emitted fstp.
Rewrite FP_EX_INEXACT handling.
2013-11-06 Joseph Myers <joseph@codesourcery.com> 2013-11-06 Joseph Myers <joseph@codesourcery.com>
......
...@@ -48,7 +48,7 @@ __sfp_handle_exceptions (int _fex) ...@@ -48,7 +48,7 @@ __sfp_handle_exceptions (int _fex)
{ {
float f = 0.0f; float f = 0.0f;
#ifdef __x86_64__ #ifdef __x86_64__
volatile float r; volatile float r __attribute__ ((unused));
asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f)); asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f));
r = f; /* Needed to trigger exception. */ r = f; /* Needed to trigger exception. */
#else #else
...@@ -68,7 +68,7 @@ __sfp_handle_exceptions (int _fex) ...@@ -68,7 +68,7 @@ __sfp_handle_exceptions (int _fex)
{ {
float f = 1.0f, g = 0.0f; float f = 1.0f, g = 0.0f;
#ifdef __x86_64__ #ifdef __x86_64__
volatile float r; volatile float r __attribute__ ((unused));
asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g)); asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g));
r = f; /* Needed to trigger exception. */ r = f; /* Needed to trigger exception. */
#else #else
...@@ -94,11 +94,15 @@ __sfp_handle_exceptions (int _fex) ...@@ -94,11 +94,15 @@ __sfp_handle_exceptions (int _fex)
} }
if (_fex & FP_EX_INEXACT) if (_fex & FP_EX_INEXACT)
{ {
struct fenv temp; float f = 1.0f, g = 3.0f;
asm volatile ("fnstenv\t%0" : "=m" (temp)); #ifdef __x86_64__
temp.__status_word |= FP_EX_INEXACT; volatile float r __attribute__ ((unused));
asm volatile ("fldenv\t%0" : : "m" (temp)); asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g));
asm volatile ("fwait"); 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment