Martin Mares <mj@ucw.cz> wrote on 2010/04/27 09:47:36:
Hello!
Huh, what should do endianity have in common with the choice of pre-/postincrement?
Because most archs that can deal with preinc. are big endian, the for loop is important too. Decrement and test for zero is basically free.
If GCC generates obviously suboptimal code on some platform, fix GCC or at least file a bug report. Trying to outwit the compiler by re-arranging the source code in various magical ways can work only with specific combinations of compiler + version + platform, so your code will need constant monitoring and updating as the compilers evolve, which is a maintenance disaster.
Fixing gcc is simpler said than done. Many have tried but gcc is simply not the compiler to use if you want speed. The current impl. is just what you say you don't want to support. The "while(buf < end)" is tailored to be fast on x86 and harder to maintain than the simpler and more natural "for (; len; --len)" loop. I have spent enough time on this now, if anyone wants to profile please do. Jocke