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] Call math_opt_barrier inside if


Since floating-point operation may trigger floating-point exceptions,
we call math_opt_barrier inside if to prevent code motion.

Tested on x86-64.  OK for trunk?

H.J.
---
	[BZ #19465]
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Call math_opt_barrier
	inside if.
---
 sysdeps/ieee754/dbl-64/s_fma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index bc3677d..a349243 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -175,7 +175,10 @@ __fma (double x, double y, double z)
 
   /* Ensure correct sign of exact 0 + 0.  */
   if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
-    return x * y + z;
+    {
+      x = math_opt_barrier (x);
+      return x * y + z;
+    }
 
   fenv_t env;
   libc_feholdexcept_setround (&env, FE_TONEAREST);
-- 
2.5.0


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