https://gcc.gnu.org/g:f9d7c8bd70be3e32494d5427d98e0841f8fb0e62

commit f9d7c8bd70be3e32494d5427d98e0841f8fb0e62
Author: Michael Matz <[email protected]>
Date:   Tue Mar 20 16:23:28 2018 +0100

    Remove most recompute_tree_invariant_for_addr_expr
    
    most aren't necessary as of now (testsuite clean relative to
    former patches).  Retain the one in gimplifier and build1().

Diff:
---
 gcc/gimple-ssa-evrp.c       | 2 +-
 gcc/gimplify-me.c           | 3 +++
 gcc/omp-expand.c            | 2 +-
 gcc/omp-low.c               | 8 +++++---
 gcc/tree-cfg.c              | 6 +++---
 gcc/tree-inline.c           | 4 ++--
 gcc/tree-nested.c           | 4 ++--
 gcc/tree-ssa-dom.c          | 2 +-
 gcc/tree-ssa-forwprop.c     | 2 +-
 gcc/tree-ssa-phionlycprop.c | 2 +-
 gcc/tree-ssa-propagate.c    | 2 +-
 gcc/tree-ssa-sccvn.c        | 2 +-
 gcc/tree.c                  | 8 +++++++-
 13 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c
index c9bbf09a4064..d316423fc832 100644
--- a/gcc/gimple-ssa-evrp.c
+++ b/gcc/gimple-ssa-evrp.c
@@ -198,7 +198,7 @@ evrp_dom_walker::before_dom_children (basic_block bb)
          if (gimple_assign_single_p (stmt))
            {
              tree rhs = gimple_assign_rhs1 (stmt);
-             if (TREE_CODE (rhs) == ADDR_EXPR)
+             if (0 && TREE_CODE (rhs) == ADDR_EXPR)
                recompute_tree_invariant_for_addr_expr (rhs);
            }
        }
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index bb9b9141de56..0a43649f8e5a 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -49,6 +49,9 @@ force_gimple_operand_1 (tree expr, gimple_seq *stmts,
 
   *stmts = NULL;
 
+  if (0 && TREE_CODE (expr) == VAR_DECL
+      && DECL_HAS_VALUE_EXPR_P (expr))
+    expr = DECL_VALUE_EXPR (expr);
   /* gimple_test_f might be more strict than is_gimple_val, make
      sure we pass both.  Just checking gimple_test_f doesn't work
      because most gimple predicates do not work recursively.  */
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index d2a77c067c6c..a4693f9a667e 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -1068,7 +1068,7 @@ expand_omp_regimplify_p (tree *tp, int *walk_subtrees, 
void *)
   if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
     return t;
 
-  if (TREE_CODE (t) == ADDR_EXPR)
+  if (0 && TREE_CODE (t) == ADDR_EXPR)
     recompute_tree_invariant_for_addr_expr (t);
 
   *walk_subtrees = !TYPE_P (t) && !DECL_P (t);
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d8588b9faed0..d7b547edae24 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -6923,13 +6923,15 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context 
*ctx)
       rhs_p = gimple_omp_for_initial_ptr (stmt, i);
       if (!is_gimple_min_invariant (*rhs_p))
        *rhs_p = get_formal_tmp_var (*rhs_p, &body);
-      else if (TREE_CODE (*rhs_p) == ADDR_EXPR)
+      else if (0 && TREE_CODE (*rhs_p) == ADDR_EXPR)
+       /* As we use fold on address computations which were TREE_CONSTANT,
+          we need to reset that flag in case they aren't anymore.  */
        recompute_tree_invariant_for_addr_expr (*rhs_p);
 
       rhs_p = gimple_omp_for_final_ptr (stmt, i);
       if (!is_gimple_min_invariant (*rhs_p))
        *rhs_p = get_formal_tmp_var (*rhs_p, &body);
-      else if (TREE_CODE (*rhs_p) == ADDR_EXPR)
+      else if (0 && TREE_CODE (*rhs_p) == ADDR_EXPR)
        recompute_tree_invariant_for_addr_expr (*rhs_p);
 
       rhs_p = &TREE_OPERAND (gimple_omp_for_incr (stmt, i), 1);
@@ -8689,7 +8691,7 @@ lower_omp_regimplify_p (tree *tp, int *walk_subtrees,
 
   /* If a global variable has been privatized, TREE_CONSTANT on
      ADDR_EXPR might be wrong.  */
-  if (data == NULL && TREE_CODE (t) == ADDR_EXPR)
+  if (0 && data == NULL && TREE_CODE (t) == ADDR_EXPR)
     recompute_tree_invariant_for_addr_expr (t);
 
   *walk_subtrees = !IS_TYPE_OR_DECL_P (t);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 7fe7966489ac..65224a2314a8 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2023,7 +2023,7 @@ replace_uses_by (tree name, tree val)
                /* Operands may be empty here.  For example, the labels
                   of a GIMPLE_COND are nulled out following the creation
                   of the corresponding CFG edges.  */
-               if (op && TREE_CODE (op) == ADDR_EXPR)
+               if (0 && op && TREE_CODE (op) == ADDR_EXPR)
                  recompute_tree_invariant_for_addr_expr (op);
              }
 
@@ -3000,7 +3000,7 @@ gimple_split_edge (edge edge_in)
 static bool 
 verify_address (tree t, bool verify_addressable)
 {
-  bool old_constant;
+  /*bool old_constant;
   bool old_side_effects;
   bool new_constant;
   bool new_side_effects;
@@ -3021,7 +3021,7 @@ verify_address (tree t, bool verify_addressable)
     {
       error ("side effects not recomputed when ADDR_EXPR changed");
       return true;
-    }
+    }*/
 
   tree base = TREE_OPERAND (t, 0);
   while (handled_component_p (base))
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 0aa7bd13ae35..b7828fe96118 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1015,7 +1015,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void 
*data)
             TREE_CONSTANT and friends are up-to-date.  */
          int invariant = is_gimple_min_invariant (*tp);
          walk_tree (&TREE_OPERAND (*tp, 0), remap_gimple_op_r, data, NULL);
-         recompute_tree_invariant_for_addr_expr (*tp);
+         //recompute_tree_invariant_for_addr_expr (*tp);
 
          /* If this used to be invariant, but is not any longer,
             then regimplification is probably needed.  */
@@ -1301,7 +1301,7 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void 
*data)
                t = fold_convert (remap_type (TREE_TYPE (*tp), id), t);
              *tp = t;
            }
-         else
+         else if (0)
            recompute_tree_invariant_for_addr_expr (*tp);
 
          /* If this used to be invariant, but is not any longer,
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index d8998af66673..4f6339d32380 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1040,7 +1040,7 @@ convert_nonlocal_reference_op (tree *tp, int 
*walk_subtrees, void *data)
               referencing a decl.  */
            save_context = current_function_decl;
            current_function_decl = info->context;
-           recompute_tree_invariant_for_addr_expr (t);
+           //recompute_tree_invariant_for_addr_expr (t);
            current_function_decl = save_context;
 
            /* If the callback converted the address argument in a context
@@ -1721,7 +1721,7 @@ convert_local_reference_op (tree *tp, int *walk_subtrees, 
void *data)
 
          save_context = current_function_decl;
          current_function_decl = info->context;
-         recompute_tree_invariant_for_addr_expr (t);
+         //recompute_tree_invariant_for_addr_expr (t);
          current_function_decl = save_context;
 
          /* If we are in a context where we only accept values, then
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 329aed6da0d6..f83dcda0c926 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1957,7 +1957,7 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, 
gimple_stmt_iterator si)
         /* This should never be an ADDR_EXPR.  */
         rhs = gimple_switch_index (swtch_stmt);
 
-      if (rhs && TREE_CODE (rhs) == ADDR_EXPR)
+      if (0 && rhs && TREE_CODE (rhs) == ADDR_EXPR)
         recompute_tree_invariant_for_addr_expr (rhs);
 
       /* Indicate that maybe_clean_or_replace_eh_stmt needs to be called,
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 31286868c34f..609e0fc98aa2 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -639,7 +639,7 @@ tidy_after_forward_propagate_addr (gimple *stmt)
   if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
     bitmap_set_bit (to_purge, gimple_bb (stmt)->index);
 
-  if (TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR)
+  if (0 && TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR)
      recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt));
 }
 
diff --git a/gcc/tree-ssa-phionlycprop.c b/gcc/tree-ssa-phionlycprop.c
index 0cd501aa3cbe..afe8af1bebb1 100644
--- a/gcc/tree-ssa-phionlycprop.c
+++ b/gcc/tree-ssa-phionlycprop.c
@@ -227,7 +227,7 @@ propagate_rhs_into_lhs (gimple *stmt, tree lhs, tree rhs,
 
          /* If we replaced a variable index with a constant, then
             we would need to update the invariant flag for ADDR_EXPRs.  */
-          if (gimple_assign_single_p (use_stmt)
+          if (0 && gimple_assign_single_p (use_stmt)
               && TREE_CODE (gimple_assign_rhs1 (use_stmt)) == ADDR_EXPR)
            recompute_tree_invariant_for_addr_expr
                 (gimple_assign_rhs1 (use_stmt));
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index 9f67a9ab1113..77ca9e96c853 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -1117,7 +1117,7 @@ substitute_and_fold_dom_walker::before_dom_children 
(basic_block bb)
            {
              tree rhs = gimple_assign_rhs1 (stmt);
 
-             if (TREE_CODE (rhs) == ADDR_EXPR)
+             if (0 && TREE_CODE (rhs) == ADDR_EXPR)
                recompute_tree_invariant_for_addr_expr (rhs);
            }
 
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 4da4d105e80d..9f5a5a243a45 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -5721,7 +5721,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
        {
          /* If a formerly non-invariant ADDR_EXPR is turned into an
             invariant one it was on a separate stmt.  */
-         if (gimple_assign_single_p (stmt)
+         if (0 && gimple_assign_single_p (stmt)
              && TREE_CODE (gimple_assign_rhs1 (stmt)) == ADDR_EXPR)
            recompute_tree_invariant_for_addr_expr (gimple_assign_rhs1 (stmt));
          gimple_stmt_iterator prev = gsi;
diff --git a/gcc/tree.c b/gcc/tree.c
index 3f37d2bb4222..bd2cef3dcb11 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3388,6 +3388,7 @@ decl_address_invariant_p (const_tree op)
   /* The conditions below are slightly less strict than the one in
      staticp.  */
 
+again:
   switch (TREE_CODE (op))
     {
     case PARM_DECL:
@@ -3397,6 +3398,11 @@ decl_address_invariant_p (const_tree op)
       return true;
 
     case VAR_DECL:
+      if (DECL_HAS_VALUE_EXPR_P (op))
+       {
+         op = DECL_VALUE_EXPR (CONST_CAST(tree, op));
+         goto again;
+       }
       if ((TREE_STATIC (op) || DECL_EXTERNAL (op))
           || DECL_THREAD_LOCAL_P (op)
           || DECL_CONTEXT (op) == current_function_decl
@@ -4898,7 +4904,7 @@ build_invariant_address (tree type, tree base, poly_int64 
offset)
                          build_fold_addr_expr (base),
                          build_int_cst (ptr_type_node, offset));
   tree addr = build1 (ADDR_EXPR, type, ref);
-  recompute_tree_invariant_for_addr_expr (addr);
+  //recompute_tree_invariant_for_addr_expr (addr);
   return addr;
 }

Reply via email to