Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Put your code... (was Re: gotos
Message-ID: <1988Apr30.220253.15058@utzoo.uucp>
Organization: U of Toronto Zoology
References: <2597@ttrdc.UUCP> <165600043@uiucdcsb> <1988Apr27.164212.12535@utzoo.uucp>, <2800@bsu-cs.UUCP>
Date: Sat, 30 Apr 88 22:02:53 GMT

>... 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
