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]

Re: [tree-ssa] DCE fixes


On Fri, 22 Nov 2002, Andrew Macleod wrote:

> This patch makes the DCE pass functional. The number of c-torture failures
> is reduced to 58 additional failures over not using DCE.
> 
> DCE cannot currently be run in tandem with CCP since we're missing a few bits
> which maintain the SSA web between passes. That should be fixed shortly.
> In order to run DCE, you currently need to specify 
>   -fno-tree-ccp -ftree-dce
> 
> I have examined each of the 58 additional c-torture failures, and found the
> following 6 classes of failures:
> 
> 1 - nested scoped references are missing in the SSA representation right now.
>       t = ....
>       {
>         int x[t];
> 	....
>       }
> 
>   there is no reference to t available in the declaration stmt, so DCE thinks 
>   't = ...' is dead and removes it and all feeding statements.
> 
Yeah.  We don't include declarations inside basic blocks, so the
variable reference finder doesn't even see them.  I'm still not
sure what the best way of dealing with this could be.  Perhaps
scanning declarations and adding uses in the last basic block for
every dynamically-sized array?

> 2 - points to type with no variable instance -  aliasing.
>   given:
>      x->y->t = 1;
>   we get something like:
> 
>      t1=x->y
>      t2=y1->t
>      *t3=1
> 
>   and with no actual variable of y2->t, aliasing currently indicates that
>   *t3 isn't aliased with aything, so it looks like an unneeded store to a local
>   and removes it along with all feeding statements.
> 
> 3 - assignment aliasing.
>   char *p = buf + 125
> 
>   p and buf are not aliased, so all *p stores are consideredstores to locals
>   serving no purpose, and so are removed.
> 
> 4 - aliasing is non-associative.
>   *x alaises *p,
>   *p aliases *z
>   *x currently doesn't have *z as an alias.
> 
All these issues should be trivial with points-to analysis.  Dan,
how long do you think it would take to get a bootstrapping
compiler with -ftree-points-to=steen?  I tried today and it fails
building print-rtl1.o with stage1/xgcc.

The tree-alias-* code seems to have lots of debugging output as
well.  I guess it needs a bit of cleanup?


> 5 - Null statements terminate looping through a block.
>   when statements are removed, they are replaced with a common null_statement 
>   node.  gsi_step_bb() uses bb_for_stmt() to determine which block the current
>   stmt is in, so we can never iterate past a deleted stmt.
> 
We could do the TF_STMT_DELETED idea.  The call to remove_stmt
could mark them and then after DCE we could commit all the
deletions.

> 6 - var-args sometimes generate odd looking instructions such as 
>   ap = ap which have unadvertised side-effects. It looks like they are 2
>   different 'ap's, and perhaps the var-arg builtin it is feeding is refering
>   to the wrong 'ap'. When this stmt is deleted, we fail to generate some 
>   addressing instructions which cause a few failures.
> 
Blech.  I guess we should mark varargs nodes non-gimple :(

> Here's the DCE patch. Comments? OK to commit on the branch?
> 
The patch looks OK to me.  Let's get it in so it helps fixing the
infrastructure bugs you found.


Diego.


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