From: Chris Moore <moore@free.fr>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible
Date: Thu, 08 Oct 2009 07:23:05 +0200 [thread overview]
Message-ID: <4ACD7739.8040800@free.fr> (raw)
In-Reply-To: <b03f28d4c4afa0c5c9f2421b7d260a0f3890cdcd.1254904388.git.rubini@ unipv.it>
Alessandro Rubini a ?crit :
> From: Alessandro Rubini <rubini@unipv.it>
>
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
> ---
> lib_generic/string.c | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/lib_generic/string.c b/lib_generic/string.c
> index 181eda6..fdccab6 100644
> --- a/lib_generic/string.c
> +++ b/lib_generic/string.c
> @@ -449,7 +449,16 @@ char * bcopy(const char * src, char * dest, int count)
> void * memcpy(void * dest,const void *src,size_t count)
> {
> char *tmp = (char *) dest, *s = (char *) src;
> + u32 *d32 = (u32 *)dest, *s32 = (u32 *) src;
>
> + /* if both are aligned, use 32-bit copy */
> + if ( (((int)dest & 3) | ((int)src & 3) | (count & 3)) == 0 ) {
>
This can be factorized as (a & 3) | (b & 3) | (c & 3) is equivalent to
(a | b | c) & 3.
GCC is pretty smart but I doubt that it will pick this up :(
> + count /= 4;
> + while (count--)
> + *d32++ = *s32++;
> + return dest;
> + }
> + /* else, use 1-byte copy */
> while (count--)
> *tmp++ = *s++;
>
>
Cheers,
Chris
next prev parent reply other threads:[~2009-10-08 5:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 8:44 [U-Boot] [PATCH 0/3] make memcpy and memset 32-bit copies Alessandro Rubini
2009-10-07 8:44 ` [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible Alessandro Rubini
2009-10-07 8:52 ` Mike Frysinger
2009-10-07 8:59 ` Alessandro Rubini
2009-10-07 9:30 ` Wolfgang Denk
2009-10-08 7:41 ` Alessandro Rubini
2009-10-08 8:37 ` Wolfgang Denk
2009-10-08 9:05 ` Joakim Tjernlund
2009-10-08 12:49 ` Wolfgang Denk
2009-10-08 13:29 ` Joakim Tjernlund
2009-10-08 13:47 ` Wolfgang Denk
2009-10-10 16:09 ` Eric Lammerts
2009-10-07 14:35 ` Peter Tyser
2009-10-07 17:04 ` Mike Frysinger
2009-10-07 8:44 ` [U-Boot] [PATCH 2/3] memset: " Alessandro Rubini
2009-10-07 9:27 ` Wolfgang Denk
2009-10-07 8:44 ` [U-Boot] [PATCH 3/3] lcd: remove '#if 0' 32-bit scroll, now memcpy does it Alessandro Rubini
[not found] ` <b03f28d4c4afa0c5c9f2421b7d260a0f3890cdcd.1254904388.git.rubini@unipv.it>
2009-10-08 5:23 ` Chris Moore [this message]
2009-10-08 6:05 ` [U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ACD7739.8040800@free.fr \
--to=moore@free.fr \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox