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: [PATCH] PR14841 and PR15838


On Tuesday 31 August 2004 22:48, Richard Henderson wrote:
> On Tue, Aug 31, 2004 at 07:16:16PM +0200, Steven Bosscher wrote:
> > +   return (TREE_CODE (var) == VAR_DECL
> > + 	  && TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE
> > + 	  && TREE_READONLY (var)
> > + 	  && DECL_INITIAL (var)
> > + 	  && TREE_CODE (DECL_INITIAL (var)) == CONSTRUCTOR
> > + 	  && ! TREE_SIDE_EFFECTS (DECL_INITIAL (var)));
>
> This test is not complete.  You need to check targetm.binds_local_p.
> You ought to be checking TREE_STATIC.  The TREE_SIDE_EFFECTS check
> is pointless.

Hmm I understand why we need the binds_local_p check,
but why TREE_STATIC, is TREE_READONLY not enough?

>
> > +   return (TREE_CODE (var) == VAR_DECL
> > + 	  && TREE_CODE (TREE_TYPE (var)) == RECORD_TYPE
> > + 	  && TREE_CODE (TREE_OPERAND (t, 1)) == FIELD_DECL
> > + 	  && TREE_READONLY (var)
> > + 	  && DECL_INITIAL (var)
> > + 	  && TREE_CODE (DECL_INITIAL (var)) == CONSTRUCTOR
> > + 	  && ! TREE_SIDE_EFFECTS (DECL_INITIAL (var)));
>
> The variable test is largely replicated here -- bad.

Well, you want me to introduce yet _another_ predicate?  This is
what Diego asked for.  I don't like it much either.

> You're not handling nested components/arrays.  Try
>
> 	x = a.b.c.d.e[2].f[4].g

Neither does expr.c as far as I can tell.  This was supposed to
fix just the deficiency that expr.c handles the simpler cases,
which are a major source of missed optimizations in gcc itself,
with checking enabled.


> All of this should be done in fold or fold_stmt, so that passes
> other than ccp can make use of it.

It would have to be in fold_stmt then, I guess.

Gr.
Steven



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