This is the mail archive of the libc-alpha@sources.redhat.com 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: Support inline SSE/SSE2


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)


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