gotos and optimization

Walter Bright bright at nazgul.UUCP
Thu Oct 25 07:45:52 AEST 1990


In article <201 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:
<Actually, there is a good chance that you lost efficiency rather than gained
<it.  Many optimizing compilers don't deal well with goto's.

The parser for Zortech C/C++ actually translates all control structures
into a sequence of basic blocks connected by goto's. The optimizer detects
loops and other structures by analyzing the goto's. It uses standard
algorithms (presented in books like Aho and Ullman's "Compilers").
There is nothing particularly difficult about it, I'd even say it was easier
than trying to deal with the original structures.

The optimizer is able to find the loops in even the worst rat's nest of
goto's.

I suggest that avoiding goto's because they might optimize poorly is not
a particularly useful strategy. If your optimizing compiler is so bad that
it doesn't use algorithms available at B. Dalton's, perhaps you should
send the vendor a complimentary copy of the Dragon book! :-)



More information about the Comp.lang.c mailing list