> 1. In VS 6.0 (on Intel H/W) (are unsigned better?)
So, you pick one specific processor / compiler combination out of the many 10's of processors (or maybe hundreds of variants, or thousands of compilers + flag variations) and decide that proves it?
Interesting it may be, but it's not in my "useful" things to know when it comes to getting the best out of the code.
The whole point of using a HLL is to stop you from having to worry about the minutia of how specific machines handle specific cases, and thus allow you to concentrate on the bigger issues.
Any (let me say it again for the hard of reading,
ANY) attempt at performance optimisation before you've finished the program and done some meaningful profiling is a waste of time. Focus your effort on choosing good data structures and algorithms, which will save hours (or months) of computing time, and let the compiler worry about the microseconds.
Your fast loop won't mean squat if you were dumb enough to put it in a bubble sort for example. There isn't an optimiser out there which can spot a bubble sort and decide to replace it with quicksort. That's YOUR job, so do it.
If you're finding your "optimised" code hard to read, then for sure so will the compilers' optimiser, and it will just chicken out and do exactly what you asked for.
Take those ridiculous attempts at swapping variables (without a temp) for example.
What could possibly be wrong with
{ int temp = a ; a = b ; b = temp; }
printf( "%d %d\n", a, b );
Simple, obvious, and more importantly, TRANSPARENT to the optimiser. My recent version of gcc for example optimised this out to (wait for it)
printf( "%d %d\n", b, a ); That's right, the swap is GONE!
An extreme case maybe, but it does illustrate that if the code is clear in it's purpose, then the optimiser may just get rid of it and find another way to get to where you want to be.
With all those swap tricks, the optimiser is left with "Huh?, WTF is that" and you get exactly what you asked for.
Compilers have evolved a lot since the 1980's, so stop recycling all those 1980's tricks. They either don't work, are unnecessary or just make it worse.