]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-pre.c (name_to_id): New global.
authorRichard Guenther <rguenther@suse.de>
Wed, 6 Jan 2010 17:08:25 +0000 (17:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 6 Jan 2010 17:08:25 +0000 (17:08 +0000)
2010-01-06  Richard Guenther  <rguenther@suse.de>

* tree-ssa-pre.c (name_to_id): New global.
(alloc_expression_id): Simplify SSA name handling.
(lookup_expression_id): Likewise.
(init_pre): Zero name_to_id.
(fini_pre): Free it.

From-SVN: r155676

gcc/ChangeLog
gcc/tree-ssa-pre.c

index 501c8d91e819fc4ee6daaac169546a3f18693925..bb99a9fea27a67d77657fc3fb81398e2bf994708 100644 (file)
@@ -1,3 +1,11 @@
+2010-01-06  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-pre.c (name_to_id): New global.
+       (alloc_expression_id): Simplify SSA name handling.
+       (lookup_expression_id): Likewise.
+       (init_pre): Zero name_to_id.
+       (fini_pre): Free it.
+
 2010-01-06  Uros Bizjak  <ubizjak@gmail.com>
 
        * ifcvt.c (if_convert): Output slim multiple dumps with TDF_SLIM.
index 972af001a76f2f14cc9a6ef75155855719f999b4..cafebe677702f795b6cb27add30d6fbabb04ecad 100644 (file)
@@ -236,6 +236,7 @@ DEF_VEC_P (pre_expr);
 DEF_VEC_ALLOC_P (pre_expr, heap);
 static VEC(pre_expr, heap) *expressions;
 static htab_t expression_to_id;
+static VEC(unsigned, heap) *name_to_id;
 
 /* Allocate an expression id for EXPR.  */
 
@@ -247,9 +248,23 @@ alloc_expression_id (pre_expr expr)
   gcc_assert (next_expression_id + 1 > next_expression_id);
   expr->id = next_expression_id++;
   VEC_safe_push (pre_expr, heap, expressions, expr);
-  slot = htab_find_slot (expression_to_id, expr, INSERT);
-  gcc_assert (!*slot);
-  *slot = expr;
+  if (expr->kind == NAME)
+    {
+      unsigned version = SSA_NAME_VERSION (PRE_EXPR_NAME (expr));
+      /* VEC_safe_grow_cleared allocates no headroom.  Avoid frequent
+        re-allocations by using VEC_reserve upfront.  There is no
+        VEC_quick_grow_cleared unfortunately.  */
+      VEC_reserve (unsigned, heap, name_to_id, num_ssa_names);
+      VEC_safe_grow_cleared (unsigned, heap, name_to_id, num_ssa_names);
+      gcc_assert (VEC_index (unsigned, name_to_id, version) == 0);
+      VEC_replace (unsigned, name_to_id, version, expr->id);
+    }
+  else
+    {
+      slot = htab_find_slot (expression_to_id, expr, INSERT);
+      gcc_assert (!*slot);
+      *slot = expr;
+    }
   return next_expression_id - 1;
 }
 
@@ -266,10 +281,20 @@ lookup_expression_id (const pre_expr expr)
 {
   void **slot;
 
-  slot = htab_find_slot (expression_to_id, expr, NO_INSERT);
-  if (!slot)
-    return 0;
-  return ((pre_expr)*slot)->id;
+  if (expr->kind == NAME)
+    {
+      unsigned version = SSA_NAME_VERSION (PRE_EXPR_NAME (expr));
+      if (VEC_length (unsigned, name_to_id) <= version)
+       return 0;
+      return VEC_index (unsigned, name_to_id, version);
+    }
+  else
+    {
+      slot = htab_find_slot (expression_to_id, expr, NO_INSERT);
+      if (!slot)
+       return 0;
+      return ((pre_expr)*slot)->id;
+    }
 }
 
 /* Return the existing expression id for EXPR, or create one if one
@@ -4483,6 +4508,7 @@ init_pre (bool do_fre)
   value_expressions = VEC_alloc (bitmap_set_t, heap, get_max_value_id () + 1);
   VEC_safe_grow_cleared (bitmap_set_t, heap, value_expressions,
                         get_max_value_id() + 1);
+  name_to_id = NULL;
 
   in_fre = do_fre;
 
@@ -4544,6 +4570,7 @@ fini_pre (bool do_fre)
   free_alloc_pool (pre_expr_pool);
   htab_delete (phi_translate_table);
   htab_delete (expression_to_id);
+  VEC_free (unsigned, heap, name_to_id);
 
   FOR_ALL_BB (bb)
     {