Does "C" really optimize? - No, and why not

Dan Klein dvk at mi-cec.UUCP
Wed Feb 15 05:00:13 AEST 1984


This is a continuation of my diatribe on "C doesn't optimize, it neatens".
Some time ago I made the rash statement that "C does not have an optimizer,
it has a neatener".  I also threatened to make good my statement by proving
it.

I have posted to net.lang.c a collection of examples on how C fails to create
very good code.  Rather than state what *I* could have done were *I* a
compiler (easy to say, hard to implement), I show what a compiler with an
optimizer is capable of.  To accomplish this, I have compared the output of
4.1c BSD "C" with VAX/VMS "Bliss-32".  Identical program fragments were fed
to both compilers, and the resultant assembly code is presented and discussed.
While a number of the optimizations require flow analysis (something "C" does
very little or none of), some suggestions can be incorporated into the
"Optimizer" pass of "C".  (Are you listening, maintainers?)

I have taken pains *not* to compare Bliss with C (syntax, semantics, or
capabilities), but concentrate on the ability of the compilers to optimize.
In all cases, no tricks were used to get one language to behave better than
another, and in all cases the default level of optimization was used.  The
unexpurgated assembly code is given; the only neatening I have done is to
insert tabs for readability.  Any and all counterexamples are welcome.  (If
you don't have a Bliss compiler, I can run tests for you, depending on the
size and number of requests).

		-Dan Klein, Mellon Institute, Pittsburgh	(412)578-3382



More information about the Comp.lang.c mailing list