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] Fix PR35607, another revenge of invariant addresses (ivopts)


On Mon, 17 Mar 2008, Diego Novillo wrote:

> On Mon, Mar 17, 2008 at 09:06, Diego Novillo <dnovillo@google.com> wrote:
> 
> >  bool
> >  is_gimple_invariant (const_tree t)
> >  {
> >   if (TREE_CODE (t) == ADDR_EXPR)
> >      return address_invariant_p (t);
> >   else
> >      return is_gimple_const (t);
> >  }
> >
> >  And is_gimple_const() is the same is_gimple_min_invariant() we have
> >  today minus ADDR_EXPR handling.
> >
> >  Thoughts?
> 
> Forgot something.  This may slow things down a little bit.  In which
> case we could figure something out.  I much prefer this to the
> recompute_tree_invariant_for_addr_expr business, though.

Yes.  address_invariant_p should be simply

  t = TREE_OPERAND (t, 0);
  while (handled_component_p (t))
  {
 	  if ((TREE_CODE (t) == ARRAY_REF
 	       || TREE_CODE (t) == ARRAY_RANGE_REF)
 	      && !is_gimple_const (TREE_OPERAND (t, 1)))
 	    return false;
 	  t = TREE_OPERAND (t, 0);
 }
 return true;

(and reject non-NULL operands 2, 3 from array_ref and component_ref).

Richard.


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