tree-ssa-sccvn.c (try_to_simplify): Use valid_gimple_expression
authorDaniel Berlin <dberlin@dberlin.org>
Wed, 18 Jul 2007 15:44:28 +0000 (15:44 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Wed, 18 Jul 2007 15:44:28 +0000 (15:44 +0000)
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.

From-SVN: r126721

gcc/ChangeLog
gcc/tree-ssa-propagate.c
gcc/tree-ssa-sccvn.c

index 5cf3884..df4a611 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2007-07-18  Rask Ingemann Lambertsen  <rask@sygehus.dk>
 
        PR target/32808
index 096664d..4803362 100644 (file)
@@ -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 53e680c..589058f 100644 (file)
@@ -1437,7 +1437,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. */