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] Expand mempcpy into memcpy


This makes all mempcpy call to call memcpy instead.

There are two reasons, one is that it will simplify maintainance. 
Second is that posible performance gains are saving one addition and
perhaps spilling one register. Problem is that implementation is quite
big - 1105 bytes on x64. Probably cost of instruction/branch cache
misses outweigth speedup we gained.

I will move unused inline functions later.

2013-02-06   OndÅej BÃlka  <neleai@seznam.cz>

	* string/bits/string2.h (mempcpy): Expand into memcpy call.


diff --git a/string/bits/string2.h b/string/bits/string2.h
index 8b6a36f..377a74f 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -202,21 +202,13 @@ __STRING2_COPY_TYPE (8);
 #ifdef __USE_GNU
 # if !defined _HAVE_STRING_ARCH_mempcpy || defined _FORCE_INLINES
 #  ifndef _HAVE_STRING_ARCH_mempcpy
-#   if __GNUC_PREREQ (3, 4)
-#    define __mempcpy(dest, src, n) __builtin_mempcpy (dest, src, n)
-#   elif __GNUC_PREREQ (3, 0)
-#    define __mempcpy(dest, src, n) \
-  (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
-		  && __string2_1bptr_p (src) && n <= 8			      \
-		  ? __builtin_memcpy (dest, src, n) + (n)		      \
-		  : __mempcpy (dest, src, n)))
-#   else
-#    define __mempcpy(dest, src, n) \
-  (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n)      \
-		  && __string2_1bptr_p (src) && n <= 8			      \
-		  ? __mempcpy_small (dest, __mempcpy_args (src), n)	      \
-		  : __mempcpy (dest, src, n)))
-#   endif
+
+#   define __mempcpy(dest, src, n) \
+   ( __extension__ ({							       \
+     size_t __n = (n);							       \
+     memcpy (dest, src, __n) + __n;					       \
+   }))
+
 /* In glibc we use this function frequently but for namespace reasons
    we have to use the name `__mempcpy'.  */
 #   define mempcpy(dest, src, n) __mempcpy (dest, src, n)


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