[comp.lang.c] gotos and optimization

bright@nazgul.UUCP (Walter Bright) (10/25/90)

In article <201@smds.UUCP> rh@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! :-)