Put your code... (was Re: gotos
Barnacle Wes
wes at obie.UUCP
Mon May 2 09:51:27 AEST 1988
In article <1988Apr27.164212.12535 at utzoo.uucp> henry at utzoo.uucp (Henry
Spencer) writes:
| It doesn't take much of an optimizer
| to notice that the instruction sequences preceding an unconditional control-
| flow merge are identical, and condense them into one by branching to the
| beginning of the sequence rather than the end. Any peephole optimizer
| worthy of the name ought to be willing to do this.
In article <2800 at bsu-cs.UUCP>, dhesi at bsu-cs.UUCP (Rahul Dhesi) replies:
> My reading of the original article by kenny at uiucdcsb.cs.uiuc.edu is
> that kenny's example (a CPU simulator) would duplicate code in such a
> way that a peephole optimizer would not find it. 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.
This form of optimization is called "common subexpression removal."
It is quite often used to optimize for space (less code space is
required, obviously). It would NOT commonly be used if you are
looking for the utmost in speed, the time spent jumping into/out of
the common code does not make for faster programs.
--
/\ - "Against Stupidity, - {backbones}!
/\/\ . /\ - The Gods Themselves - utah-cs!uplherc!
/ \/ \/\/ \ - Contend in Vain." - sp7040!obie!
/ U i n T e c h \ - Schiller - wes
More information about the Comp.lang.c
mailing list