Philippe Ranger wrote:
> > << > Consequently, it is not the best generalized > approach to these types of loops. Now since classes are actually > pointers it is easy to see that the preponderance of arrays fall into > this catagory, and so I believe that the compiler should handle them > differently. This was my "wish". > >> > > I suppose the array access by pointer incrementation is valid for While > loops too, so you're not saying the For is less optimized than the While, > but that in the former case there's an extra optimization available for the > most common use, and it is not put in.
The while loop really isn't optimized at all in the way for loops are. A while loop is handled more like a bent if-then statement. Consequently, you can manually optimize access within the loop by proper use of pointers, indicies etc. But you have to do it all yourself. I would prefer if the already complex for loop optimizations were made a bit more complex and treated arrays of simple sized elements differently.
> provided for this (with the loop operator), and now that the optimizer is > smarter by a degree of magnitude, somehow this former, trivial, optimization > hasn't been removed to free a reg. Have I got this right?
Nope, like I said the ecx usage was coincidental. Toss a routine call into the loop and the counter will be shifted to a protected register like esi.
-- Bob Lee High Performance Delphi - http://www.econos.com/optimize/ Updated August 2