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, Richard Guenther wrote:

> 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

Like that one.

Can we rely on TREE_INVARIANT on the base object of the reference
tree or shall we open-code that as well (hm, I wasn't able to
quickly come up with the correct thing here ;)).

RIchard.

Index: tree-gimple.h
===================================================================
*** tree-gimple.h	(revision 133287)
--- tree-gimple.h	(working copy)
*************** extern bool is_gimple_addressable (tree)
*** 62,67 ****
--- 62,71 ----
  /* Returns true iff T is any valid GIMPLE lvalue.  */
  extern bool is_gimple_lvalue (tree);
  
+ /* Returns true iff T is a GIMPLE invariant address.  */
+ bool is_gimple_invariant_address (const_tree);
+ /* Returns true iff T is a valid GIMPLE constant.  */
+ bool is_gimple_const (const_tree);
  /* Returns true iff T is a GIMPLE restricted function invariant.  */
  extern bool is_gimple_min_invariant (const_tree);
  /* Returns true iff T is a GIMPLE rvalue.  */
Index: tree-gimple.c
===================================================================
*** tree-gimple.c	(revision 133287)
--- tree-gimple.c	(working copy)
*************** is_gimple_addressable (tree t)
*** 167,183 ****
  	  || INDIRECT_REF_P (t));
  }
  
! /* Return true if T is a GIMPLE minimal invariant.  It's a restricted
!    form of function invariant.  */
  
  bool
! is_gimple_min_invariant (const_tree t)
  {
    switch (TREE_CODE (t))
      {
-     case ADDR_EXPR:
-       return TREE_INVARIANT (t);
- 
      case INTEGER_CST:
      case REAL_CST:
      case FIXED_CST:
--- 167,179 ----
  	  || INDIRECT_REF_P (t));
  }
  
! /* Return true if T is a valid gimple constant.  */
  
  bool
! is_gimple_const (const_tree t)
  {
    switch (TREE_CODE (t))
      {
      case INTEGER_CST:
      case REAL_CST:
      case FIXED_CST:
*************** is_gimple_min_invariant (const_tree t)
*** 198,203 ****
--- 194,248 ----
      }
  }
  
+ /* Return true if T is a gimple invariant address.  */
+ 
+ bool
+ is_gimple_invariant_address (const_tree t)
+ {
+   tree op;
+ 
+   if (TREE_CODE (t) != ADDR_EXPR)
+     return false;
+ 
+   op = TREE_OPERAND (t, 0);
+   while (handled_component_p (t))
+     {
+       switch (TREE_CODE (t))
+ 	{
+ 	case ARRAY_REF:
+ 	case ARRAY_RANGE_REF:
+ 	  if (!is_gimple_constant (TREE_OPERAND (t, 1))
+ 	      || TREE_OPERAND (t, 2) != NULL_TREE
+ 	      || TREE_OPERAND (t, 3) != NULL_TREE)
+ 	    return false;
+ 	  break;
+ 
+ 	case COMPONENT_REF:
+ 	  if (TREE_OPERAND (t, 2) != NULL_TREE
+ 	      || TREE_OPERAND (t, 3) != NULL_TREE)
+ 	    return false;
+ 	  break;
+ 
+ 	default:;
+ 	}
+       op = TREE_OPERAND (t, 0);
+     }
+ 
+   return TREE_INVARIANT (op);
+ }
+ 
+ /* Return true if T is a GIMPLE minimal invariant.  It's a restricted
+    form of function invariant.  */
+ 
+ bool
+ is_gimple_min_invariant (const_tree t)
+ {
+   if (TREE_CODE (t) == ADDR_EXPR)
+     return is_gimple_invariant_address (t);
+ 
+   return is_gimple_constant (t);
+ }
+ 
  /* Return true if T looks like a valid GIMPLE statement.  */
  
  bool


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