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] Implement optimized libc_fe*() math routines on sparc.


I have been eyeing this for a while, this minimizes the number of
times we load/store the %fsr during state changes in the math
library as well as eliminate all the function calls the generic
version was doing.

Committed to master.

	* sysdeps/sparc/fpu/math_private.h: New file.
---
 ChangeLog                        |    4 ++
 sysdeps/sparc/fpu/math_private.h |   68 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 sysdeps/sparc/fpu/math_private.h

diff --git a/ChangeLog b/ChangeLog
index bb85537..a5d592e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-03-16  David S. Miller  <davem@davemloft.net>
+
+	* sysdeps/sparc/fpu/math_private.h: New file.
+
 2012-03-15  David S. Miller  <davem@davemloft.net>
 
 	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fma-vis3.S: New file.
diff --git a/sysdeps/sparc/fpu/math_private.h b/sysdeps/sparc/fpu/math_private.h
new file mode 100644
index 0000000..05ef623
--- /dev/null
+++ b/sysdeps/sparc/fpu/math_private.h
@@ -0,0 +1,68 @@
+#ifndef SPARC_MATH_PRIVATE_H
+#define SPARC_MATH_PRIVATE_H 1
+
+#include_next <math_private.h>
+#include <fenv.h>
+
+#undef libc_feholdexcept
+#define libc_feholdexcept(e) \
+  do {							\
+     fenv_t etmp;					\
+     __fenv_stfsr(etmp);				\
+     *(e) = etmp;					\
+     etmp = etmp & ~((0x1f << 23) | FE_ALL_EXCEPT);	\
+     __fenv_ldfsr(etmp);				\
+  } while (0)
+#undef libc_feholdexceptf
+#define libc_feholdexceptf(e) libc_feholdexcept (e)
+#undef libc_feholdexceptl
+#define libc_feholdexceptl(e) libc_feholdexcept (e)
+
+#undef libc_feholdexcept_setround
+#define libc_feholdexcept_setround(e, r) \
+  do {							\
+     fenv_t etmp;					\
+     __fenv_stfsr(etmp);				\
+     *(e) = etmp;					\
+     etmp = etmp & ~((0x1f << 23) | FE_ALL_EXCEPT);	\
+     etmp = (etmp & ~__FE_ROUND_MASK) | (r);		\
+     __fenv_ldfsr(etmp);				\
+  } while (0)
+#undef libc_feholdexcept_setroundf
+#define libc_feholdexcept_setroundf(e, r) libc_feholdexcept_setround (e, r)
+#undef libc_feholdexcept_setroundl
+#define libc_feholdexcept_setroundl(e, r) libc_feholdexcept_setround (e, r)
+
+#undef libc_fetestexcept
+#define libc_fetestexcept(e) \
+  ({							\
+     fenv_t etmp;					\
+     __fenv_stfsr(etmp);				\
+     etmp & (e) & FE_ALL_EXCEPT; })
+#undef libc_fetestexceptf
+#define libc_fetestexceptf(e) libc_fetestexcept (e)
+#undef libc_fetestexceptl
+#define libc_fetestexceptl(e) libc_fetestexcept (e)
+
+#undef libc_fesetenv
+#define libc_fesetenv(e) \
+  __fenv_ldfsr(*e)
+#undef libc_fesetenvf
+#define libc_fesetenvf(e) libc_fesetenv (e)
+#undef libc_fesetenvl
+#define libc_fesetenvl(e) libc_fesetenv (e)
+
+#undef libc_feupdateenv
+#define libc_feupdateenv(e) \
+  do {						\
+     fenv_t etmp;				\
+     __fenv_stfsr(etmp);			\
+     __fenv_ldfsr(*e);				\
+     __feraiseexcept (etmp & FE_ALL_EXCEPT);	\
+  } while (0)
+#undef libc_feupdateenvf
+#define libc_feupdateenvf(e) libc_feupdateenv (e)
+#undef libc_feupdateenvl
+#define libc_feupdateenvl(e) libc_feupdateenv (e)
+
+#endif /* SPARC_MATH_PRIVATE_H */
-- 
1.7.9.1


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