svn commit: trunk/uClibc/libc/string/i386
vda at uclibc.org
vda at uclibc.org
Tue Dec 9 13:24:00 UTC 2008
Author: vda
Date: 2008-12-09 05:23:59 -0800 (Tue, 09 Dec 2008)
New Revision: 24346
Log:
smaller memcpy
text data bss dec hex filename
- 39 0 0 39 27 libc/string/i386/memcpy.os
+ 35 0 0 35 23 libc/string/i386/memcpy.os
Modified:
trunk/uClibc/libc/string/i386/memcpy.c
Changeset:
Modified: trunk/uClibc/libc/string/i386/memcpy.c
===================================================================
--- trunk/uClibc/libc/string/i386/memcpy.c 2008-12-09 11:38:52 UTC (rev 24345)
+++ trunk/uClibc/libc/string/i386/memcpy.c 2008-12-09 13:23:59 UTC (rev 24346)
@@ -35,19 +35,20 @@
/* Experimentally off - libc_hidden_proto(memcpy) */
void *memcpy(void * to, const void * from, size_t n)
{
- int d0, d1, d2;
- __asm__ __volatile__(
- "rep ; movsl\n\t"
- "testb $2,%b4\n\t"
- "je 1f\n\t"
- "movsw\n"
- "1:\ttestb $1,%b4\n\t"
- "je 2f\n\t"
- "movsb\n"
- "2:"
- : "=&c" (d0), "=&D" (d1), "=&S" (d2)
- :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
- : "memory");
- return (to);
+ int d0, d1, d2;
+ __asm__ __volatile__(
+ " rep; movsl\n"
+ " movl %4,%%ecx\n"
+ " andl $3,%%ecx\n"
+ /* jz is optional. avoids "rep; movsb" with ecx == 0,
+ * but adds a branch, which is currently (2008) faster */
+ " jz 1f\n"
+ " rep; movsb\n"
+ "1:\n"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ : "0" (n / 4), "g" (n), "1" ((long)to), "2" ((long)from)
+ : "memory"
+ );
+ return to;
}
libc_hidden_def(memcpy)
More information about the uClibc-cvs
mailing list