summaryrefslogtreecommitdiff
path: root/libatomic/config/x86/fenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'libatomic/config/x86/fenv.c')
-rw-r--r--libatomic/config/x86/fenv.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/libatomic/config/x86/fenv.c b/libatomic/config/x86/fenv.c
index d7b1bbe5ea1..d972a99f594 100644
--- a/libatomic/config/x86/fenv.c
+++ b/libatomic/config/x86/fenv.c
@@ -47,6 +47,12 @@ struct fenv
unsigned short int __unused5;
};
+#ifdef __SSE_MATH__
+# define __math_force_eval(x) asm volatile ("" : : "x" (x));
+#else
+# define __math_force_eval(x) asm volatile ("" : : "f" (x));
+#endif
+
/* Raise the supported floating-point exceptions from EXCEPTS. Other
bits in EXCEPTS are ignored. */
@@ -56,12 +62,7 @@ __atomic_feraiseexcept (int excepts)
if (excepts & FE_INVALID)
{
float f = 0.0f;
-#ifdef __SSE_MATH__
- asm volatile ("%vdivss\t{%0, %d0|%d0, %0}" : "+x" (f));
-#else
- asm volatile ("fdiv\t{%y0, %0|%0, %y0}" : "+t" (f));
- /* No need for fwait, exception is triggered by emitted fstp. */
-#endif
+ __math_force_eval (f / f);
}
if (excepts & FE_DENORM)
{
@@ -74,12 +75,7 @@ __atomic_feraiseexcept (int excepts)
if (excepts & FE_DIVBYZERO)
{
float f = 1.0f, g = 0.0f;
-#ifdef __SSE_MATH__
- asm volatile ("%vdivss\t{%1, %d0|%d0, %1}" : "+x" (f) : "xm" (g));
-#else
- asm volatile ("fdivs\t%1" : "+t" (f) : "m" (g));
- /* No need for fwait, exception is triggered by emitted fstp. */
-#endif
+ __math_force_eval (f / g);
}
if (excepts & FE_OVERFLOW)
{