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]

[PATCH]: Fix g++.dg/opt/pr24665.C


This fixes the regression caused by sccvn where pr24665.C now
propagates an invalid gimple expression around from DECL_INITIAL.


Bootstrapped and regtested on i686-darwin.


Okay for mainline?
2007-07-18  Daniel Berlin  <dberlin@dberlin.org>

	* tree-ssa-sccvn.c (try_to_simplify): Use valid_gimple_expression
	* tree-ssa-propagate (valid_gimple_expression): Handle ADDR_EXPR
	properly.
Index: tree-ssa-sccvn.c
===================================================================
--- tree-ssa-sccvn.c	(revision 126568)
+++ tree-ssa-sccvn.c	(working copy)
@@ -1435,7 +1435,7 @@ try_to_simplify (tree stmt, tree rhs)
 	  if (TREE_READONLY (rhs)
 	      && TREE_STATIC (rhs)
 	      && DECL_INITIAL (rhs)
-	      && is_gimple_min_invariant (DECL_INITIAL (rhs)))
+	      && valid_gimple_expression_p (DECL_INITIAL (rhs)))
 	    return DECL_INITIAL (rhs);
 
 	    /* Fallthrough. */
Index: tree-ssa-propagate.c
===================================================================
--- tree-ssa-propagate.c	(revision 126566)
+++ tree-ssa-propagate.c	(working copy)
@@ -606,10 +606,21 @@ valid_gimple_expression_p (tree expr)
       switch (code)
 	{
 	case ADDR_EXPR:
-          if (TREE_CODE (TREE_OPERAND (expr, 0)) == ARRAY_REF
-	      && !is_gimple_val (TREE_OPERAND (TREE_OPERAND (expr, 0), 1)))
-	    return false;
-	  break;
+         {
+           tree t = TREE_OPERAND (expr, 0);
+           while (handled_component_p (t))
+             {
+               /* ??? More checks needed, see the GIMPLE verifier.  */
+               if ((TREE_CODE (t) == ARRAY_REF
+                    || TREE_CODE (t) == ARRAY_RANGE_REF)
+                   && !is_gimple_val (TREE_OPERAND (t, 1)))
+                 return false;
+               t = TREE_OPERAND (t, 0);
+             }
+           if (!is_gimple_addressable (t))
+             return false;
+           break;
+         }
 
 	case TRUTH_NOT_EXPR:
 	  if (!is_gimple_val (TREE_OPERAND (expr, 0)))

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