This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add a barrier in the double fma implementation


Starting with version 4.6, GCC started to reorder instructions in 
the double fma implementation, leading to wrong results in some cases,
at least on MIPS (detected by test-double and test-idouble).

The patch below applies the same strategy than in commit 7c08a05c, 
adding a barrier between the computation and the FP exception test.


2012-02-15  Aurelien Jarno  <aurelien@aurel32.net>

       * sysdeps/ieee754/dbl-64/s_fma.c (__fma): Ensure a1 + u.d
       computation is not scheduled after fetestexcept.

---
 sysdeps/ieee754/dbl-64/s_fma.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -174,6 +174,8 @@
       if ((u.ieee.mantissa1 & 1) == 0)
 	u.ieee.mantissa1 |= libc_fetestexcept (FE_INEXACT) != 0;
       v.d = a1 + u.d;
+      /* Ensure the addition is not scheduled after fetestexcept call.  */
+      asm volatile ("" : : "m" (v));
       int j = libc_fetestexcept (FE_INEXACT) != 0;
       libc_feupdateenv (&env);
       /* Ensure the following computations are performed in default rounding

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]