Dear Joakim Tjernlund, In message <of26fea2cb.36e102ee-onc1257649.0031301d-c1257649.0031e...@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). It does not matter. The generated code is identical. What matters might be compiler options - "-Os" generates a small loop, and "-O3" and higher will unroll the loop, which is way more code. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de When you die, the first thing you lose is your life. The next thing is the illusions. - Terry Pratchett, _Pyramids_ _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot