micro-optimizing loops (was Help with casts)

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Feb 25 06:32:58 AEST 1991


What Chris doesn't point out is that

  i = blah;
  do
   {
    ...
   }
  while (--i);

will compile to the optimal code on most machines under most compilers,
whether they have condition codes or not, whether they have exposed jump
delays or not, and whether the optimizer is on or off. I don't know any
machines where this will produce worse code than any other expression of
the loop.

---Dan



More information about the Comp.lang.c mailing list