public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] crc32: Correct endianness of crc32 result
Date: Wed, 17 Apr 2013 21:23:26 +0200	[thread overview]
Message-ID: <20130417212326.4f803bfb@lilith> (raw)
In-Reply-To: <CAPnjgZ1mR3h5fqCrhAuj4wN_4YCD4iO_VBnM76rHupnpowXHZg@mail.gmail.com>

Hi Simon -- and sorry for the dupe.

On Wed, 17 Apr 2013 11:28:07 -0700, Simon Glass <sjg@chromium.org>
wrote:

> I tried using:
> 
> #ifdef USE_HOSTCC
>    crc = htobe32(crc);
> #else
>    crc = cpu_to_be32(crc);
> #endif
>    memcpy(output, &crc, sizeof(crc));
> 
> 
> This is one instruction (4 bytes, 16%) smaller, but I suspect quite a
> lot slower due to the overhead of a very small memcpy().
> 
> 43e2c1d8: e28d1008 add r1, sp, #8
> 43e2c1dc: e3a02004 mov r2, #4
> 43e2c1e0: e6bf0f30 rev r0, r0
> 43e2c1e4: e5210004 str r0, [r1, #-4]!
> 43e2c1e8: e1a00004 mov r0, r4
> 43e2c1ec: eb001af7 bl 43e32dd0 <memcpy>

How about replacing the memcpy with an explicit put_unaligned(),
similar to what was done in

http://www.mail-archive.com/u-boot at lists.denx.de/msg109555.html

with get_unaligned()? The code will be longer than above, but shorter
than the above plus the memcpy(), and faster too -- actually, I'm
surprised that the compiler does not unroll the memcpy() on its own,
considering the size argument is a constant.

> Regards,
> Simon

Amicalement,
-- 
Albert.

  reply	other threads:[~2013-04-17 19:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 23:11 [U-Boot] [PATCH] crc32: Correct endianness of crc32 result Simon Glass
2013-04-05 23:32 ` Allen Martin
2013-04-06  7:04 ` Wolfgang Denk
2013-04-16 21:57   ` Simon Glass
2013-04-16 23:00     ` Tom Rini
2013-04-16 23:16       ` Simon Glass
2013-04-17  5:40     ` Wolfgang Denk
2013-04-17 18:28       ` Simon Glass
2013-04-17 19:23         ` Albert ARIBAUD [this message]
2013-04-17 20:59           ` Simon Glass
2013-04-18  6:20             ` Albert ARIBAUD
2013-04-18 10:36               ` Wolfgang Denk
2013-04-18 11:18                 ` Albert ARIBAUD
2013-04-18 14:39                   ` Wolfgang Denk
2013-04-18 16:39                     ` Albert ARIBAUD
2013-04-18 16:58                       ` Tom Rini
2013-04-18 18:43                         ` Albert ARIBAUD
2013-04-18 19:06                           ` Simon Glass
2013-04-18 19:18                             ` Tom Rini

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=20130417212326.4f803bfb@lilith \
    --to=albert.u.boot@aribaud.net \
    --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