[dataflow] make regscan a subpass of CSE

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Thu Mar 29 15:34:00 GMT 2007


This patch reduces the number of occasions in which the compiler
has to call regscan.  It is compile-time neutral because
I had to move df before CSE, but it is a good cleanup and fixes
various failures.

It could provide speedups at -O0, but I didn't measure that.  
I say so because we don't run regscan anymore at -O0 with
this patch.

regscan is currently run a dozen time during a compilation.
It computes the max_parallel quantity, it sets REG_N_SETS
and REG_N_REFS (which is actually something that dataflow
already does) and tries to set the REG_ATTRS and REG_POINTER
fields of a REG.

max_parallel is only necessary for global.c and can actually be
replaced with a VEC.  Computing REG_N_SETS is necessary for alias
analysis, but df_analyze also sets it and it is called for
all passes that use alias analysis (except CSE1 and GCSE),
so alias analysis may also use DF_REG_DEF_COUNT instead.

Furthermore, instrumenting gcc and bootstrapping/regtesting
yields the following numbers for the only remaining task:

     # of        times
     REG_ATTRS   REG_POINTER
     found       set to 1
133  849364      321462 (after jump2)
134  307         22
135  65          56     (before cse1)
138  8305        7720   (after gcse)
140  51          307
148  6280        1539   (after loop-done)
150  220         41
163  99          125

As can be seen, regscan does something interesting
only three times: after jump2, after GCSE (actually
before the local CSE that GCSE includes), after loop
optimizations.

Furthermore, this information is unused between jump2
and cse1, so we can delay the first (and most important)
occurrence of regscan until just before CSE1.  Likewise,
the information is unused between loop-done and CSE2.

Therefore, this patch:
1) moves DF initialization before CSE.
2) removes REG_N_SETS computation from regscan, and
adjusts alias analysis to use DF_REG_DEF_COUNT instead
3) calls reg_scan from cse_main
4) removes all other occurrences of reg_scan.
5) fixes some fallout from not running reg_scan at -O0.

Next part could be to see what's the performance fallout
from running reg_scan exactly once; it's as easy as
adding a bool argument to cse_main and I'll leave it
for later.

A previous version of the patch was tested on powerpc64 by
Kenny; this one was bootstrapped/regtested i686-pc-linux-gnu.

Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: reg-scan.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070329/9ac00a20/attachment.ksh>


More information about the Gcc-patches mailing list