[vox-tech] a comment on Pete's fast-loop question

Norm Matloff matloff at cs.ucdavis.edu
Sun Jun 18 00:06:09 PDT 2006


Pete Salzman asked about optimizing a loop in terms of execution speed,
by having the loop index go from high value to low instead of vice
versa.  Some discussion ensued in terms of what machine instructions a
compiler could take advantage of in this manner.

One point that you might consider, Pete, is that these considerations
are kind of nickel-and-dime in comparison to things like memory
hierarchy issue.  There is much better payoff potential in writing code
in such a way as to minimize cache misses, which cause major time
penalties, and page faults, which cause catastrophic time penalties.

There is even a book on this, I believe in the Intel Press series.

Norm



More information about the vox-tech mailing list