[U-Boot] [PATCH 1/3] memcpy: use 32-bit copies if possible

Joakim Tjernlund joakim.tjernlund at transmode.se
Thu Oct 8 15:29:16 CEST 2009


Wolfgang Denk <wd at denx.de> wrote on 08/10/2009 14:49:15:
>
> Dear Joakim Tjernlund,
>
> In message <OF26FEA2CB.36E102EE-ONC1257649.0031301D-C1257649.
> 0031EDAF at transmode.se> you wrote:
> >
> > > How about:
> > >
> > >       cl = 0;
> > >       for (i=0; i<sizeof(long); ++i) {
> > >          cl <<= 8;
> > >          cl |= c & 0xff;
> > >       }
> > >
> > > GCC optimization will do the rest...
> >
> > If you want gcc to optimise well, make it easy to do so.
> > Changing the for loop into:
> >       for (i=sizeof(long); i; --i)
> > makes it easier for gcc and more likely to result in optimal code.
>
> Did you actually _check_ the code? (I did).

No, but I have done this in the past and found that
gcc does stupid things sometimes, especially loops, and
it depends on arch and gcc version.

>
> It does not matter. The generated code is identical.

So my question is: Did you check all gcc versions and
arches?

 Jocke





More information about the U-Boot mailing list