PATCH: Support inline SSE/SSE2
H. J. Lu
hjl@lucon.org
Mon Nov 24 23:21:00 GMT 2003
SSE/SSE2 has float/double sqrt instructions. This patch uses them if
SSE/SSE2 is enabled.
H.J.
--------
2003-11-24 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/fpu/bits/mathinline.h (sqrt): Support SSE/SSE2.
--- sysdeps/i386/fpu/bits/mathinline.h.sse 2003-11-24 14:04:07.000000000 -0800
+++ sysdeps/i386/fpu/bits/mathinline.h 2003-11-24 14:10:28.000000000 -0800
@@ -438,8 +438,35 @@ __inline_mathcodeNP2 (fmod, __x, __y, \
#ifdef __FAST_MATH__
+# ifdef __SSE__
+# include <xmmintrin.h>
+__inline_mathcode_ (float, sqrtf, __x,
+ __extension__ union
+ {
+ __v4sf __v;
+ float __f [4];
+ } __f = { __f: {__x}};
+ __f.__v = __builtin_ia32_sqrtss (__f.__v);
+ return __f.__f [0])
+# if __GNUC_PREREQ (3,3) && defined __SSE2__
+# include <emmintrin.h>
+__inline_mathcode_ (double, sqrt, __x,
+ __extension__ union
+ {
+ __v2df __v;
+ double __d [2];
+ } __d = { __d: {__x}};
+ __d.__v = __builtin_ia32_sqrtsd (__d.__v);
+ return __d.__d [0])
+# else
+__inline_mathopNP_ (double, sqrt, "fsqrt")
+# endif
+__inline_mathopNP_ (long double, sqrtl, "fsqrt")
+__inline_mathopNP_ (long double, __sqrtl, "fsqrt")
+# else
__inline_mathopNP (sqrt, "fsqrt")
__inline_mathopNP_ (long double, __sqrtl, "fsqrt")
+# endif
#endif
#if __GNUC_PREREQ (2, 8)
More information about the Libc-alpha
mailing list