This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Eliminate useless stores patch


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?







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]