Can ANSI Standard C be "Optimized"

Dave Martindale dmmartindale at watcgl.UUCP
Mon Mar 19 04:01:35 AEST 1984


The "no optimization across statement boundaries" certainly wasn't part
of the language spec before the ANSI committee.

For as long as I can remember, the Ritchie C compiler for the PDP11
(actually c2, the optimizer) was happy to generate a SOB instruction
if it could be done.  You'll see some C code that contains loops of the
form
	if (n > 0)
		do {
			<whatever>
		} while (--n);

By putting the loop termination condition in exactly that form, you got
a SOB (Subtract One and Branch if non-zero) inserted.  Writing the code
using a while loop would have been clearer but slower.



More information about the Comp.lang.c mailing list