[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070818075602.34350b25@freepuppy.rosehill.hemminger.net>
Date: Sat, 18 Aug 2007 07:56:02 -0700
From: Stephen Hemminger <shemminger@...ux-foundation.org>
To: Andi Kleen <ak@...e.de>
Cc: discuss@...-64.org, linux-kernel@...r.kernel.org, jh@...e.cz
Subject: Re: [PATCH] x86-64: memset optimization
On Sat, 18 Aug 2007 11:46:24 +0200
Andi Kleen <ak@...e.de> wrote:
> On Saturday 18 August 2007 01:34:46 Stephen Hemminger wrote:
> > Optimize uses of memset with small constant offsets.
> > This will generate smaller code, and avoid the slow rep/string instructions.
> > Code copied from i386 with a little cleanup.
>
>
> Newer gcc should do all this on its own. That is why I intentionally
> didn't implement it on 64bit.
>
> On what compiler version did you see smaller code?
>
> -Andi
>
The problem is that on x86-64 you are overriding memset() so the builtin
version doesn't kick in. You allow gcc to inline memcpy but not memset.
What about adding code similar to memcpy() stuff.
--- a/include/asm-x86_64/string.h 2007-08-18 07:37:58.000000000 -0700
+++ b/include/asm-x86_64/string.h 2007-08-18 07:44:31.000000000 -0700
@@ -43,8 +43,13 @@ extern void *__memcpy(void *to, const vo
__ret; })
#endif
-#define __HAVE_ARCH_MEMSET
-void *memset(void *s, int c, size_t n);
+#define __HAVE_ARCH_MEMSET 1
+#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
+extern void memset(void *s, int c, size_t n);
+#else
+#define memset(s, c, n) __builtin_memset((s),(c),(n))
+#endif
+
#define __HAVE_ARCH_MEMMOVE
void * memmove(void * dest,const void *src,size_t count);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists