Put your code... (was Re: gotos

Henry Spencer henry at utzoo.uucp
Sun May 1 08:02:53 AEST 1988


>... A peephole optimizer
>scans the code through a window of limited size, and rearranges code in
>that window so that the net effect of the window remains unchanged.  I
>don't think you can remove duplicate code in different places this
>way.

"Peephole optimizer" is not a precise term nowadays; if you are willing to
stipulate one that has two windows rather than one, the optimization I
mentioned is possible.  It's not an uncommon optimization.  Even the ancient
pdp11 C compiler (the original C compiler) does it.

> ... if such duplicate code occurs only rarely,
> having everybody's compiler include such an optimizer may be overkill...

My impression is that the general case of common code before a merge point
is relatively frequent, although the common code is usually small and the
gains to be had from optimizing it are modest.  But then, nobody expects a
peephole optimizer to do anything massive.  Little improvements add up.
-- 
NASA is to spaceflight as            |  Henry Spencer @ U of Toronto Zoology
the Post Office is to mail.          | {ihnp4,decvax,uunet!mnetor}!utzoo!henry



More information about the Comp.lang.c mailing list