tree-cfg.c (verify_expr): Recurse again for invariant addresses.
authorRichard Guenther <rguenther@suse.de>
Sat, 22 Mar 2008 19:50:48 +0000 (19:50 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 22 Mar 2008 19:50:48 +0000 (19:50 +0000)
2008-03-22  Richard Guenther  <rguenther@suse.de>

* tree-cfg.c (verify_expr): Recurse again for invariant addresses.
For PHI nodes verify the address is invariant.
* tree-ssa-ccp.c (ccp_decl_initial_min_invariant): Remove.
(get_symbol_constant_value): Use is_gimple_min_invariant.
(maybe_fold_stmt_indirect): Likewise.

From-SVN: r133453

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-ssa-ccp.c

index 03ea12a..e098eb2 100644 (file)
@@ -1,3 +1,11 @@
+2008-03-22  Richard Guenther  <rguenther@suse.de>
+
+       * tree-cfg.c (verify_expr): Recurse again for invariant addresses.
+       For PHI nodes verify the address is invariant.
+       * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): Remove.
+       (get_symbol_constant_value): Use is_gimple_min_invariant.
+       (maybe_fold_stmt_indirect): Likewise.
+
 2008-03-22  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        PR rtl-optimization/33927
index c4b9bff..6c4b311 100644 (file)
@@ -3172,7 +3172,14 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
           we may be missing "valid" checks, but what can you do?
           This was PR19217.  */
         if (in_phi)
-         break;
+         {
+           if (!is_gimple_min_invariant (t))
+             {
+               error ("non-invariant address expression in PHI argument");
+               return t;
+             }
+           break;
+         }
 
        old_invariant = TREE_INVARIANT (t);
        old_constant = TREE_CONSTANT (t);
@@ -3216,10 +3223,6 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
            return x;
          }
 
-       /* Stop recursing and verifying invariant ADDR_EXPRs, they tend
-          to become arbitrary complicated.  */
-       if (is_gimple_min_invariant (t))
-         *walk_subtrees = 0;
        break;
       }
 
index 7797de1..805776a 100644 (file)
@@ -267,31 +267,6 @@ debug_lattice_value (prop_value_t val)
 }
 
 
-/* The regular is_gimple_min_invariant does a shallow test of the object.
-   It assumes that full gimplification has happened, or will happen on the
-   object.  For a value coming from DECL_INITIAL, this is not true, so we
-   have to be more strict ourselves.  */
-
-static bool
-ccp_decl_initial_min_invariant (tree t)
-{
-  if (!is_gimple_min_invariant (t))
-    return false;
-  if (TREE_CODE (t) == ADDR_EXPR)
-    {
-      /* Inline and unroll is_gimple_addressable.  */
-      while (1)
-       {
-         t = TREE_OPERAND (t, 0);
-         if (is_gimple_id (t))
-           return true;
-         if (!handled_component_p (t))
-           return false;
-       }
-    }
-  return true;
-}
-
 /* If SYM is a constant variable with known value, return the value.
    NULL_TREE is returned otherwise.  */
 
@@ -304,7 +279,7 @@ get_symbol_constant_value (tree sym)
     {
       tree val = DECL_INITIAL (sym);
       if (val
-         && ccp_decl_initial_min_invariant (val))
+         && is_gimple_min_invariant (val))
        return val;
       /* Variables declared 'const' without an initializer
         have zero as the intializer if they may not be
@@ -1990,7 +1965,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
 
       /* Fold away CONST_DECL to its value, if the type is scalar.  */
       if (TREE_CODE (base) == CONST_DECL
-         && ccp_decl_initial_min_invariant (DECL_INITIAL (base)))
+         && is_gimple_min_invariant (DECL_INITIAL (base)))
        return DECL_INITIAL (base);
 
       /* Try folding *(&B+O) to B.X.  */