Optimizing Compilers
Kenneth Almquist
ka at cbosgd.UUCP
Fri Jan 11 09:48:22 AEST 1985
> The point is where do you draw the line? Not
> that an optimizer should NEVER change an effect.
Normally, the rule is that an optimizing compiler should conform
to the language standard. In C, for example, the order of evaluation
of expressions is explicitly undefined in most cases. Thus an optimizer
may reorder expressions to improve efficiency, even if this changes the
behavior of the program.
The case under discussion involved moving a division by zero out of a
loop so that only 1 exception rather than 100 exceptions are generated.
For many languages this would be OK because the effects of of a program
that performs divisions by zero are left undefined. In the case of C,
the situation is somewhat different because C is used for a variety
of systems programming type jobs which require that the code generated
by the compiler be unsurprising. The proposed ANSI standard for C
makes this optimization invalid.
Kenneth Almquist
More information about the Comp.unix.wizards
mailing list