mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 2.6.17-rc5 2/2] i386 memcpy: minor optimization
@ 2006-05-31  0:59 Chuck Ebbert
  0 siblings, 0 replies; only message in thread
From: Chuck Ebbert @ 2006-05-31  0:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton, Linus Torvalds

Skip an additional instruction if memcpy size is divisible by four.

Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>

--- 2.6.17-rc5-32.orig/include/asm-i386/string.h
+++ 2.6.17-rc5-32/include/asm-i386/string.h
@@ -203,20 +203,20 @@ return __res;
 
 static __always_inline void * __memcpy(void * to, const void * from, size_t n)
 {
-int d0, d1, d2;
+int d0, d1, d2, d3;
 __asm__ __volatile__(
 	"rep ; movsl\n\t"
-	"movl %4,%%ecx\n\t"
-	"andl $3,%%ecx\n\t"
-#if 1	/* want to pay 2 byte penalty for a chance to skip microcoded rep? */
+	"andl $3,%3\n\t"
+#if 1	/* want to pay 2 byte penalty for a chance to skip a mov and a microcoded rep? */
 	"jz 1f\n\t"
 #endif
+	"movl %3,%%ecx\n\t"
 	"rep ; movsb\n\t"
 	"1:"
-	: "=&c" (d0), "=&D" (d1), "=&S" (d2)
-	: "0" (n/4), "g" (n), "1" ((long) to), "2" ((long) from)
+	: "=&c" (d0), "=&D" (d1), "=&S" (d2), "=&g" (d3)
+	: "0" (n/4), "1" ((long) to), "2" ((long) from), "3" (n)
 	: "memory");
-return (to);
+return to;
 }
 
 /*
-- 
Chuck

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-05-31  1:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-31  0:59 [patch 2.6.17-rc5 2/2] i386 memcpy: minor optimization Chuck Ebbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®