Excessive optimization (was Re: what was VMS/OpenVMS written in?)
eric at brouhaha.com
Thu Dec 2 14:29:14 CST 2010
Ethan Dicks wrote:
> 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.
If the compiler optimized that out entirely, the compiler is defective.
Optimizations are not supposed to change the semantics of well-formed code.
On the other hand, the compiler is free to optimize
for (i = 0; i < 100; i++)
i = 100;
Since that does not change the semantics.
More information about the cctalk