Excessive optimization (was Re: what was VMS/OpenVMS written in?)

Ethan Dicks ethan.dicks at gmail.com
Thu Dec 2 13:47:49 CST 2010


On Wed, Dec 1, 2010 at 9:42 PM, Chuck Guzis <cclist at sydex.com> wrote:
> The Microsoft issue, I recall was with dead code elimination.  The C
> expression
>
>        while( C != 0);
>
> could normally be eliminated if C was 0...

I have used the following in embedded code to tight-loop the CPU in
certain circumstances, intentionally requiring a reset of the
processor to escape...

for (;;)
  ;

I suppose a good optimizer would know that you really meant to do that
and should produce something resembling the following

$1: JMP $1

...but I certainly wouldn't want that statement optimized out entirely.

> The beauty of a good optimizer is that it allows one to write legible
> code that still turns in good performance.

Indeed.

The horror of a bad optimizer (and I _have_ seen this) is that it
introduces bugs that vanish when the optimizer is turned off.

-ethan



More information about the cctech mailing list