optimization/5738: GCSE missed optimization

law@redhat.com law@redhat.com
Thu Apr 4 08:26:00 GMT 2002


 In message <Pine.LNX.4.44.0204030807080.6886-100000@dberlin.org>, Daniel 
Berlin
 > > No, the main object of PRE (besides performing GCSE) is to suppress 
 > > partial redundancies. 
 > > IE expressions that are available along one or more paths, but missing fro
 > m some path.
 > > It does so by making it fully redundant, copying it to a block (or 
 > > blocks) such that it reaches all of the paths.  It then eliminates the 
 > > other copies.
 > 
 > See, for instance http://www.cs.rice.edu/~keith/512/Lectures/LCM.pdf, 
 > which explains this quite well in the first few pages.
As does Morgan, Muchnick and the various papers in PLDI.  Our implementation
is directly derived from Morgan.

 > we have something like
 > 
 > if (b)
 > {
 > 	a;
 > 	c;
 > }
 > else
 > {
 > 	a;
 > 	d;
 > }
 > 
 > which is a job for PRE.
If you have something like this, then that's not a job for PRE/LCM as no
path through the CFG has more than one evaluation of "a".

What you're looking for is actually tail merging, which would drop "a"
down the CFG.  If you wanted to move "a" up in the CFG you should look 
at the code hoisting code, which we enable at -Os.

Jeff




More information about the Gcc-bugs mailing list