]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-cfg.c (gimple_can_merge_blocks_p): Do more fine-grained check whether SSA form...
authorRichard Guenther <rguenther@suse.de>
Fri, 27 Jul 2012 13:57:38 +0000 (13:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 27 Jul 2012 13:57:38 +0000 (13:57 +0000)
2012-07-27  Richard Guenther  <rguenther@suse.de>

* tree-cfg.c (gimple_can_merge_blocks_p): Do more fine-grained
check whether SSA form is not up-to-date.
* tree-flow.h (name_mappings_registered_p): Remove.
* tree-into-ssa.c (struct repl_map_d): Remove.
(repl_tbl): Likewise.
(struct ssa_name_info): Add repl_set member.
(update_ssa_obstack): New static global.
(get_ssa_name_ann): Initialize repl_set.
(clear_ssa_name_info): Assert age did not wrap.
(repl_map_hash, repl_map_eq, repl_map_free): Remove.
(names_replaced_by): Adjust.
(add_to_repl_tbl): Likewise.
(dump_tree_ssa_stats): Likewise.
(init_update_ssa): Initialize update_ssa_obstack.
(delete_update_ssa): Free update_ssa_obstack.
(name_mappings_registered_p): Remove.
(update_ssa): Adjust.

From-SVN: r189915

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-flow.h
gcc/tree-into-ssa.c

index 13f1da70ab4f07776119926b537972191dad7699..3e89d0b999e08e8372c5f3e5e49b501fa753c3db 100644 (file)
@@ -1,3 +1,23 @@
+2012-07-27  Richard Guenther  <rguenther@suse.de>
+
+       * tree-cfg.c (gimple_can_merge_blocks_p): Do more fine-grained
+       check whether SSA form is not up-to-date.
+       * tree-flow.h (name_mappings_registered_p): Remove.
+       * tree-into-ssa.c (struct repl_map_d): Remove.
+       (repl_tbl): Likewise.
+       (struct ssa_name_info): Add repl_set member.
+       (update_ssa_obstack): New static global.
+       (get_ssa_name_ann): Initialize repl_set.
+       (clear_ssa_name_info): Assert age did not wrap.
+       (repl_map_hash, repl_map_eq, repl_map_free): Remove.
+       (names_replaced_by): Adjust.
+       (add_to_repl_tbl): Likewise.
+       (dump_tree_ssa_stats): Likewise.
+       (init_update_ssa): Initialize update_ssa_obstack.
+       (delete_update_ssa): Free update_ssa_obstack.
+       (name_mappings_registered_p): Remove.
+       (update_ssa): Adjust.
+
 2012-07-27  Segher Boessenkool  <segher@kernel.crashing.org>
 
         * config/rs6000/constraints.md: Delete "q" constraint.
index 2615de3bd35d7d867423353e8f9715983e433bb4..29b4e9886ea778d10ec41304059da4700b7dcf0b 100644 (file)
@@ -1445,7 +1445,6 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
 {
   gimple stmt;
   gimple_stmt_iterator gsi;
-  gimple_seq phis;
 
   if (!single_succ_p (a))
     return false;
@@ -1495,10 +1494,13 @@ gimple_can_merge_blocks_p (basic_block a, basic_block b)
   /* It must be possible to eliminate all phi nodes in B.  If ssa form
      is not up-to-date and a name-mapping is registered, we cannot eliminate
      any phis.  Symbols marked for renaming are never a problem though.  */
-  phis = phi_nodes (b);
-  if (!gimple_seq_empty_p (phis)
-      && name_mappings_registered_p ())
-    return false;
+  for (gsi = gsi_start_phis (b); !gsi_end_p (gsi); gsi_next (&gsi))
+    {
+      gimple phi = gsi_stmt (gsi);
+      /* Technically only new names matter.  */
+      if (name_registered_for_update_p (PHI_RESULT (phi)))
+       return false;
+    }
 
   /* When not optimizing, don't merge if we'd lose goto_locus.  */
   if (!optimize
index 75f91871cf0eb142229de3d2bc21ad1214a7d00c..454445d8637c00e4543674d4178711f3a8a3140e 100644 (file)
@@ -570,7 +570,6 @@ void delete_update_ssa (void);
 void register_new_name_mapping (tree, tree);
 tree create_new_def_for (tree, gimple, def_operand_p);
 bool need_ssa_update_p (struct function *);
-bool name_mappings_registered_p (void);
 bool name_registered_for_update_p (tree);
 void release_ssa_name_after_update_ssa (tree);
 void compute_global_livein (bitmap, bitmap);
index 37558cbf53707dc04623f163a96e0784b77c7ec0..bc70642cdc9d9c0618e518e02f30c91a22f289a9 100644 (file)
@@ -128,18 +128,6 @@ static bitmap blocks_with_phis_to_rewrite;
    strategy.  */
 #define NAME_SETS_GROWTH_FACTOR        (MAX (3, num_ssa_names / 3))
 
-/* Tuple used to represent replacement mappings.  */
-struct repl_map_d
-{
-  tree name;
-  bitmap set;
-};
-
-
-/* NEW -> OLD_SET replacement table.  If we are replacing several
-   existing SSA names O_1, O_2, ..., O_j with a new name N_i,
-   then REPL_TBL[N_i] = { O_1, O_2, ..., O_j }.  */
-static htab_t repl_tbl;
 
 /* The function the SSA updating data structures have been initialized for.
    NULL if they need to be initialized by register_new_name_mapping.  */
@@ -157,18 +145,21 @@ struct mark_def_sites_global_data
 /* Information stored for SSA names.  */
 struct ssa_name_info
 {
-  /* The current reaching definition replacing this SSA name.  */
-  tree current_def;
+  /* Age of this record (so that info_for_ssa_name table can be cleared
+     quickly); if AGE < CURRENT_INFO_FOR_SSA_NAME_AGE, then the fields
+     are assumed to be null.  */
+  unsigned age;
 
   /* This field indicates whether or not the variable may need PHI nodes.
      See the enum's definition for more detailed information about the
      states.  */
   ENUM_BITFIELD (need_phi_state) need_phi_state : 2;
 
-  /* Age of this record (so that info_for_ssa_name table can be cleared
-     quickly); if AGE < CURRENT_INFO_FOR_SSA_NAME_AGE, then the fields
-     are assumed to be null.  */
-  unsigned age;
+  /* The current reaching definition replacing this SSA name.  */
+  tree current_def;
+
+  /* Replacement mappings, allocated from update_ssa_obstack.  */
+  bitmap repl_set;
 };
 
 /* The information associated with names.  */
@@ -179,6 +170,8 @@ DEF_VEC_ALLOC_P (ssa_name_info_p, heap);
 static VEC(ssa_name_info_p, heap) *info_for_ssa_name;
 static unsigned current_info_for_ssa_name_age;
 
+static bitmap_obstack update_ssa_obstack;
+
 /* The set of blocks affected by update_ssa.  */
 static bitmap blocks_to_update;
 
@@ -288,6 +281,7 @@ get_ssa_name_ann (tree name)
     {
       info->need_phi_state = NEED_PHI_STATE_UNKNOWN;
       info->current_def = NULL_TREE;
+      info->repl_set = NULL;
       info->age = current_info_for_ssa_name_age;
     }
 
@@ -301,6 +295,10 @@ static void
 clear_ssa_name_info (void)
 {
   current_info_for_ssa_name_age++;
+
+  /* If current_info_for_ssa_name_age wraps we use stale information.
+     Asser that this does not happen.  */
+  gcc_assert (current_info_for_ssa_name_age != 0);
 }
 
 
@@ -573,45 +571,12 @@ is_new_name (tree name)
 }
 
 
-/* Hashing and equality functions for REPL_TBL.  */
-
-static hashval_t
-repl_map_hash (const void *p)
-{
-  return htab_hash_pointer ((const void *)((const struct repl_map_d *)p)->name);
-}
-
-static int
-repl_map_eq (const void *p1, const void *p2)
-{
-  return ((const struct repl_map_d *)p1)->name
-        == ((const struct repl_map_d *)p2)->name;
-}
-
-static void
-repl_map_free (void *p)
-{
-  BITMAP_FREE (((struct repl_map_d *)p)->set);
-  free (p);
-}
-
-
 /* Return the names replaced by NEW_TREE (i.e., REPL_TBL[NEW_TREE].SET).  */
 
 static inline bitmap
 names_replaced_by (tree new_tree)
 {
-  struct repl_map_d m;
-  void **slot;
-
-  m.name = new_tree;
-  slot = htab_find_slot (repl_tbl, (void *) &m, NO_INSERT);
-
-  /* If N was not registered in the replacement table, return NULL.  */
-  if (slot == NULL || *slot == NULL)
-    return NULL;
-
-  return ((struct repl_map_d *) *slot)->set;
+  return get_ssa_name_ann (new_tree)->repl_set;
 }
 
 
@@ -620,22 +585,10 @@ names_replaced_by (tree new_tree)
 static inline void
 add_to_repl_tbl (tree new_tree, tree old)
 {
-  struct repl_map_d m, *mp;
-  void **slot;
-
-  m.name = new_tree;
-  slot = htab_find_slot (repl_tbl, (void *) &m, INSERT);
-  if (*slot == NULL)
-    {
-      mp = XNEW (struct repl_map_d);
-      mp->name = new_tree;
-      mp->set = BITMAP_ALLOC (NULL);
-      *slot = (void *) mp;
-    }
-  else
-    mp = (struct repl_map_d *) *slot;
-
-  bitmap_set_bit (mp->set, SSA_NAME_VERSION (old));
+  bitmap *set = &get_ssa_name_ann (new_tree)->repl_set;
+  if (!*set)
+    *set = BITMAP_ALLOC (&update_ssa_obstack);
+  bitmap_set_bit (*set, SSA_NAME_VERSION (old));
 }
 
 
@@ -1719,7 +1672,7 @@ htab_statistics (FILE *file, htab_t htab)
 void
 dump_tree_ssa_stats (FILE *file)
 {
-  if (def_blocks || repl_tbl)
+  if (def_blocks)
     fprintf (file, "\nHash table statistics:\n");
 
   if (def_blocks)
@@ -1728,13 +1681,7 @@ dump_tree_ssa_stats (FILE *file)
       htab_statistics (file, def_blocks);
     }
 
-  if (repl_tbl)
-    {
-      fprintf (file, "    repl_tbl:     ");
-      htab_statistics (file, repl_tbl);
-    }
-
-  if (def_blocks || repl_tbl)
+  if (def_blocks)
     fprintf (file, "\n");
 }
 
@@ -2838,7 +2785,8 @@ init_update_ssa (struct function *fn)
   new_ssa_names = sbitmap_alloc (num_ssa_names + NAME_SETS_GROWTH_FACTOR);
   sbitmap_zero (new_ssa_names);
 
-  repl_tbl = htab_create (20, repl_map_hash, repl_map_eq, repl_map_free);
+  bitmap_obstack_initialize (&update_ssa_obstack);
+
   names_to_release = NULL;
   update_ssa_initialized_fn = fn;
 }
@@ -2858,9 +2806,6 @@ delete_update_ssa (void)
   sbitmap_free (new_ssa_names);
   new_ssa_names = NULL;
 
-  htab_delete (repl_tbl);
-  repl_tbl = NULL;
-
   bitmap_clear (SYMS_TO_RENAME (update_ssa_initialized_fn));
 
   if (names_to_release)
@@ -2885,6 +2830,9 @@ delete_update_ssa (void)
 
   BITMAP_FREE (blocks_with_phis_to_rewrite);
   BITMAP_FREE (blocks_to_update);
+
+  bitmap_obstack_release (&update_ssa_obstack);
+
   update_ssa_initialized_fn = NULL;
 }
 
@@ -2957,19 +2905,6 @@ need_ssa_update_p (struct function *fn)
              && !bitmap_empty_p (SYMS_TO_RENAME (fn))));
 }
 
-/* Return true if SSA name mappings have been registered for SSA updating.  */
-
-bool
-name_mappings_registered_p (void)
-{
-  if (!update_ssa_initialized_fn)
-    return false;
-
-  gcc_assert (update_ssa_initialized_fn == cfun);
-
-  return repl_tbl && htab_elements (repl_tbl) > 0;
-}
-
 /* Return true if name N has been registered in the replacement table.  */
 
 bool
@@ -3212,7 +3147,6 @@ update_ssa (unsigned update_flags)
     {
       sbitmap_zero (old_ssa_names);
       sbitmap_zero (new_ssa_names);
-      htab_empty (repl_tbl);
     }
 
   insert_phi_p = (update_flags != TODO_update_ssa_no_phi);