2009-04-28 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Apr 2009 08:50:19 +0000 (08:50 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Apr 2009 08:50:19 +0000 (08:50 +0000)
* tree.h (SSA_NAME_VALUE): Remove.
(struct tree_ssa_name): Remove value_handle member.
* tree-vrp.c (execute_vrp): Initialize/free the value-handle
array for jump threading.
* tree-ssa-propagate.c (ssa_prop_init): Do not initialize
SSA_NAME_VALUEs.
* print-tree.c (print_node): Do not dump SSA_NAME_VALUEs.
* tree-flow.h (threadedge_initialize_values): Declare.
(threadedge_finalize_values): Likewise.
* tree-ssa-threadedge.c (ssa_name_values): New global variable.
(SSA_NAME_VALUE): Define.
(threadedge_initialize_values): New function.
(threadedge_finalize_values): Likewise.
* tree-ssa-dom.c (ssa_name_values): New global variable.
(SSA_NAME_VALUE): Define.
(tree_ssa_dominator_optimize): Initialize/free the value-handle
array.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146877 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/print-tree.c
gcc/tree-flow.h
gcc/tree-ssa-dom.c
gcc/tree-ssa-propagate.c
gcc/tree-ssa-threadedge.c
gcc/tree-vrp.c
gcc/tree.h

index 4ca02a3..560c03c 100644 (file)
@@ -1,3 +1,23 @@
+2009-04-28  Richard Guenther  <rguenther@suse.de>
+
+       * tree.h (SSA_NAME_VALUE): Remove.
+       (struct tree_ssa_name): Remove value_handle member.
+       * tree-vrp.c (execute_vrp): Initialize/free the value-handle
+       array for jump threading.
+       * tree-ssa-propagate.c (ssa_prop_init): Do not initialize
+       SSA_NAME_VALUEs.
+       * print-tree.c (print_node): Do not dump SSA_NAME_VALUEs.
+       * tree-flow.h (threadedge_initialize_values): Declare.
+       (threadedge_finalize_values): Likewise.
+       * tree-ssa-threadedge.c (ssa_name_values): New global variable.
+       (SSA_NAME_VALUE): Define.
+       (threadedge_initialize_values): New function.
+       (threadedge_finalize_values): Likewise.
+       * tree-ssa-dom.c (ssa_name_values): New global variable.
+       (SSA_NAME_VALUE): Define.
+       (tree_ssa_dominator_optimize): Initialize/free the value-handle
+       array.
+
 2009-04-28  Ira Rosen  <irar@il.ibm.com>
 
        * tree-vect-loop-manip.c (vect_create_cond_for_alias_checks):
index 24ff249..2e51443 100644 (file)
@@ -896,14 +896,11 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
          if (SSA_NAME_IN_FREE_LIST (node))
            fprintf (file, " in-free-list");
 
-         if (SSA_NAME_PTR_INFO (node)
-             || SSA_NAME_VALUE (node))
+         if (SSA_NAME_PTR_INFO (node))
            {
              indent_to (file, indent + 3);
              if (SSA_NAME_PTR_INFO (node))
                dump_addr (file, " ptr-info ", SSA_NAME_PTR_INFO (node));
-             if (SSA_NAME_VALUE (node))
-               dump_addr (file, " value ", SSA_NAME_VALUE (node));
            }
          break;
 
index 5fe7539..a02eca5 100644 (file)
@@ -803,6 +803,14 @@ bool stmt_dominates_stmt_p (gimple, gimple);
 void mark_virtual_ops_for_renaming (gimple);
 
 /* In tree-ssa-threadedge.c */
+extern void threadedge_initialize_values (void);
+extern void threadedge_finalize_values (void);
+extern VEC(tree,heap) *ssa_name_values;
+#define SSA_NAME_VALUE(x) \
+    (SSA_NAME_VERSION(x) < VEC_length(tree, ssa_name_values) \
+     ? VEC_index(tree, ssa_name_values, SSA_NAME_VERSION(x)) \
+     : NULL_TREE)
+extern void set_ssa_name_value (tree, tree);
 extern bool potentially_threadable_block (basic_block);
 extern void thread_across_edge (gimple, edge, bool,
                                VEC(tree, heap) **, tree (*) (gimple, gimple));
index 1a851fa..a134244 100644 (file)
@@ -619,7 +619,6 @@ static unsigned int
 tree_ssa_dominator_optimize (void)
 {
   struct dom_walk_data walk_data;
-  unsigned int i;
 
   memset (&opt_stats, 0, sizeof (opt_stats));
 
@@ -659,6 +658,9 @@ tree_ssa_dominator_optimize (void)
      that we update the loop info.  */
   loop_optimizer_init (LOOPS_HAVE_SIMPLE_LATCHES);
 
+  /* Initialize the value-handle array.  */
+  threadedge_initialize_values ();
+
   /* We need accurate information regarding back edges in the CFG
      for jump threading; this may include back edges that are not part of
      a single loop.  */
@@ -716,23 +718,6 @@ tree_ssa_dominator_optimize (void)
       bitmap_zero (need_eh_cleanup);
     }
 
-  /* Finally, remove everything except invariants in SSA_NAME_VALUE.
-
-     Long term we will be able to let everything in SSA_NAME_VALUE
-     persist.  However, for now, we know this is the safe thing to do.  */
-  for (i = 0; i < num_ssa_names; i++)
-   {
-      tree name = ssa_name (i);
-      tree value;
-
-      if (!name)
-        continue;
-
-      value = SSA_NAME_VALUE (name);
-      if (value && !is_gimple_min_invariant (value))
-       SSA_NAME_VALUE (name) = NULL;
-    }
-
   statistics_counter_event (cfun, "Redundant expressions eliminated",
                            opt_stats.num_re);
   statistics_counter_event (cfun, "Constants propagated",
@@ -759,6 +744,10 @@ tree_ssa_dominator_optimize (void)
   VEC_free (tree, heap, const_and_copies_stack);
   VEC_free (gimple_p, heap, stmts_to_rescan);
   
+  /* Free the value-handle array.  */
+  threadedge_finalize_values ();
+  ssa_name_values = NULL;
+
   return 0;
 }
 
@@ -912,7 +901,7 @@ restore_vars_to_original_value (void)
        }
 
       prev_value = VEC_pop (tree, const_and_copies_stack);
-      SSA_NAME_VALUE (dest) =  prev_value;
+      set_ssa_name_value (dest, prev_value);
     }
 }
 
@@ -1124,7 +1113,7 @@ record_equivalences_from_phis (basic_block bb)
         inferred from a comparison.  All uses of this ssa name are dominated
         by this assignment, so unwinding just costs time and space.  */
       if (i == gimple_phi_num_args (phi) && may_propagate_copy (lhs, rhs))
-       SSA_NAME_VALUE (lhs) = rhs;
+       set_ssa_name_value (lhs, rhs);
     }
 }
 
@@ -1437,7 +1426,7 @@ record_conditions (struct edge_info *edge_info, tree cond, tree inverted)
 static void
 record_const_or_copy_1 (tree x, tree y, tree prev_x)
 {
-  SSA_NAME_VALUE (x) = y;
+  set_ssa_name_value (x, y);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -1956,7 +1945,7 @@ record_equivalences_from_stmt (gimple stmt, int may_optimize_p)
            fprintf (dump_file, "\n");
          }
 
-       SSA_NAME_VALUE (lhs) = rhs;
+       set_ssa_name_value (lhs, rhs);
       }
     }
 
index 89bbe08..3e8d121 100644 (file)
@@ -487,7 +487,6 @@ ssa_prop_init (void)
   edge e;
   edge_iterator ei;
   basic_block bb;
-  size_t i;
 
   /* Worklists of SSA edges.  */
   interesting_ssa_edges = VEC_alloc (gimple, gc, 20);
@@ -505,11 +504,6 @@ ssa_prop_init (void)
   cfg_blocks = VEC_alloc (basic_block, heap, 20);
   VEC_safe_grow (basic_block, heap, cfg_blocks, 20);
 
-  /* Initialize the values for every SSA_NAME.  */
-  for (i = 1; i < num_ssa_names; i++)
-    if (ssa_name (i))
-      SSA_NAME_VALUE (ssa_name (i)) = NULL_TREE;
-
   /* Initially assume that every edge in the CFG is not executable.
      (including the edges coming out of ENTRY_BLOCK_PTR).  */
   FOR_ALL_BB (bb)
index 1429c18..473bc9b 100644 (file)
@@ -49,6 +49,35 @@ along with GCC; see the file COPYING3.  If not see
    to copy as part of the jump threading process.  */
 static int stmt_count;
 
+/* Array to record value-handles per SSA_NAME.  */
+VEC(tree,heap) *ssa_name_values;
+
+/* Set the value for the SSA name NAME to VALUE.  */
+
+void
+set_ssa_name_value (tree name, tree value)
+{
+  if (SSA_NAME_VERSION (name) >= VEC_length (tree, ssa_name_values))
+    VEC_safe_grow_cleared (tree, heap, ssa_name_values,
+                          SSA_NAME_VERSION (name) + 1);
+  VEC_replace (tree, ssa_name_values, SSA_NAME_VERSION (name), value);
+}
+
+/* Initialize the per SSA_NAME value-handles array.  Returns it.  */
+void
+threadedge_initialize_values (void)
+{
+  gcc_assert (ssa_name_values == NULL);
+  ssa_name_values = VEC_alloc(tree, heap, num_ssa_names);
+}
+
+/* Free the per SSA_NAME value-handle array.  */
+void
+threadedge_finalize_values (void)
+{
+  VEC_free(tree, heap, ssa_name_values);
+}
+
 /* Return TRUE if we may be able to thread an incoming edge into
    BB to an outgoing edge from BB.  Return FALSE otherwise.  */
 
@@ -126,7 +155,7 @@ remove_temporary_equivalences (VEC(tree, heap) **stack)
        break;
 
       prev_value = VEC_pop (tree, *stack);
-      SSA_NAME_VALUE (dest) = prev_value;
+      set_ssa_name_value (dest, prev_value);
     }
 }
 
@@ -145,7 +174,7 @@ record_temporary_equivalence (tree x, tree y, VEC(tree, heap) **stack)
       y = tmp ? tmp : y;
     }
 
-  SSA_NAME_VALUE (x) = y;
+  set_ssa_name_value (x, y);
   VEC_reserve (tree, heap, *stack, 2);
   VEC_quick_push (tree, *stack, prev_x);
   VEC_quick_push (tree, *stack, x);
index 8464ffd..09c6342 100644 (file)
@@ -7277,6 +7277,7 @@ execute_vrp (void)
 
   to_remove_edges = VEC_alloc (edge, heap, 10);
   to_update_switch_stmts = VEC_alloc (switch_update, heap, 5);
+  threadedge_initialize_values ();
 
   vrp_initialize ();
   ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node);
@@ -7322,6 +7323,7 @@ execute_vrp (void)
 
   VEC_free (edge, heap, to_remove_edges);
   VEC_free (switch_update, heap, to_update_switch_stmts);
+  threadedge_finalize_values ();
 
   scev_finalize ();
   loop_optimizer_finalize ();
index d6550b5..1e58d52 100644 (file)
@@ -1854,10 +1854,6 @@ struct GTY(()) tree_exp {
 #define SSA_NAME_PTR_INFO(N) \
     SSA_NAME_CHECK (N)->ssa_name.ptr_info
 
-/* Get the value of this SSA_NAME, if available.  */
-#define SSA_NAME_VALUE(N) \
-   SSA_NAME_CHECK (N)->ssa_name.value_handle
-
 #ifndef _TREE_FLOW_H
 struct ptr_info_def;
 #endif
@@ -1896,13 +1892,6 @@ struct GTY(()) tree_ssa_name {
   /* Pointer attributes used for alias analysis.  */
   struct ptr_info_def *ptr_info;
 
-  /* Value for SSA name used by various passes.
-
-     Right now only invariants are allowed to persist beyond a pass in
-     this field; in the future we will allow VALUE_HANDLEs to persist
-     as well.  */
-  tree value_handle;
-
   /* Immediate uses list for this SSA_NAME.  */
   struct ssa_use_operand_d imm_uses;
 };