[PATCH]: Eliminate useless stores patch

Daniel Berlin dberlin@dberlin.org
Thu Jul 7 03:04:00 GMT 2005


And might as well attach the patch, too.
~/esutOn Wed, 2005-07-06 at 22:59 -0400, Daniel Berlin wrote:
> This adds a small pass to eliminate useless stores (not the same as
> dead).
> It was brought on by Kenny's static promotion pass, which generates code
> like:
> 
> static int a;
> int alocal;
> 
> alocal_5 = a
> <some number of copies and uses of alocal>
> a = alocal_5
> 
> for the copy-in/copy-out code.
> 
> Most of these stores are of course, useless since we can prove they are
> storing back the same value they have read.
> 
> DCE won't eliminate them because they are stores to global memory, and
> it doesn't know what to do there.
> 
> However, if we kill the store, DCE will then eliminate the rest of the
> code.
> 
> Without this patch, Kenny's code can slow down the compiler due to these
> useless stores being there and not being able to be eliminated.
> 
> Neither store copy or const prop will touch these because copy prop'ing
> would normally introduce *more* memory loads in the above case.  It's
> only a win in this exact pattern
> 
> The pass itself is thus a trivial pattern matcher, which is what diego
> had suggested i write, and takes roughly no compile time.
> 
> I put it in the PRE file because ideally, a real store motion would
> subsume it.
> 
> I've included a test that demonstrates the pass works :)  You can see it
> do more useful things once Kenny's code is committed.
> 
> Bootstrapped and regtested on i686-pc-linux-gnu.
> 
> Okay for mainline?
> 
> 
> 
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eustores.patch
Type: text/x-patch
Size: 5824 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050707/1bf517e3/attachment.bin>


More information about the Gcc-patches mailing list