C optimizer
Rich Neitzel
thor at stout.ucar.edu
Thu Feb 16 06:46:41 AEST 1989
In article <3684 at arcturus> evil at arcturus.UUCP (Wade Guthrie) writes:
>While we're talking about optimizers (and, since all the furor about
>optimizing one's code has died down :->), what do most optimizers on
>most C compilers do? Where is TFM that I should be 'R'ing (and in which
>FM should I look?)...
>
>What else should I expect? From what compilers? On what machines?
>In short, what should I do myself and what should I let the *general*
>optimizer/compiler do?
>
In addition, should one let the compiler do optimization? This may not
be important in most cases, but for others it can destroy the
functioning of the code. For example, many external devices have
control/status registers that are cleared only when read. An optimizer
might see code:
junk = *csr;
and since junk is never used again, remove that line. Or how about this:
while (i < length)
{
while (!(*csr & 0x80));
*storage++ = *data_reg;
}
This loop polls on a done bit and then reads the new data in the data
register. An optimizer might decide that since data_reg does not SEEM
to change, the value it points to can be put into a register and
copied from there on each pass.
Optimizing is an uncertain tool unless one knows what the optimizer is
doing. Since RISC cpus use heavily optimizing compilers and have
assemblers that are nearly impossible to follow, how does one make
certain that the optimizer hasn't shafted you? (On my 68020 I can peek
at the assembler output.) Even on CISC machines, perhaps compiler
vendors should supply a OPT_ON and OPT_OFF set of directives.
-------------------------------------------------------------------------------
Richard Neitzel
National Center For Atmospheric Research
Box 3000
Boulder, CO 80307-3000
303-497-2057
thor at thor.ucar.edu
Torren med sitt skjegg Thor with the beard
lokkar borni under sole-vegg calls the children to the sunny wall
Gjo'i med sitt shinn Gjo with the pelts
jagar borni inn. chases the children in.
-------------------------------------------------------------------------------
More information about the Comp.lang.c
mailing list