summaryrefslogtreecommitdiff
path: root/sysdeps/x86_64/fpu/bits
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-10-18 09:13:23 -0400
committerUlrich Drepper <drepper@gmail.com>2011-10-18 09:13:23 -0400
commit581d30e386b9567b973a65d0bc82af782ac078ed (patch)
tree9c4b80b4e202a38117880ccce87cb8465e2b1f51 /sysdeps/x86_64/fpu/bits
parentd38f1dba009689d78af371cffa091b27e4ebe17d (diff)
downloadglibc-581d30e386b9567b973a65d0bc82af782ac078ed.tar.gz
Add optimized nearbyint{,f} for x86-64
Diffstat (limited to 'sysdeps/x86_64/fpu/bits')
-rw-r--r--sysdeps/x86_64/fpu/bits/mathinline.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
index 6221958773..57d718db55 100644
--- a/sysdeps/x86_64/fpu/bits/mathinline.h
+++ b/sysdeps/x86_64/fpu/bits/mathinline.h
@@ -167,6 +167,24 @@ __NTH (rintf (float __x))
return __res;
}
+#ifdef __USE_ISOC99
+/* Round to nearest integer without raising inexact exception. */
+__MATH_INLINE double
+__NTH (nearbyint (double __x))
+{
+ double __res;
+ __asm ("roundsd $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
+ return __res;
+}
+__MATH_INLINE float
+__NTH (nearbyintf (float __x))
+{
+ float __res;
+ __asm ("roundss $0xc, %1, %0" : "=x" (__res) : "xm" (__x));
+ return __res;
+}
+#endif
+
__END_NAMESPACE_C99
# endif