OSDN Git Service

2010-01-04 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jan 2010 21:02:42 +0000 (21:02 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jan 2010 21:02:42 +0000 (21:02 +0000)
* tree-ssa-sccvn.c (get_or_alloc_constant_value_id): Allocate
a new entry only if needed.
* tree-ssa-dom.c (lookup_avail_expr): Likewise.
* tree-ssa-coalesce.c (find_coalesce_pair): Avoid one
hashtable lookup.
* tree-ssa-pre.c (sorted_array_from_bitmap_set): Pre-allocate
the result array.
(phi_translate): Handle CONSTANTs early.

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

gcc/ChangeLog
gcc/tree-ssa-coalesce.c
gcc/tree-ssa-dom.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-sccvn.c

index e622c8f..370fb45 100644 (file)
@@ -1,3 +1,14 @@
+2010-01-04  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-sccvn.c (get_or_alloc_constant_value_id): Allocate
+       a new entry only if needed.
+       * tree-ssa-dom.c (lookup_avail_expr): Likewise.
+       * tree-ssa-coalesce.c (find_coalesce_pair): Avoid one
+       hashtable lookup.
+       * tree-ssa-pre.c (sorted_array_from_bitmap_set): Pre-allocate
+       the result array.
+       (phi_translate): Handle CONSTANTs early.
+
 2010-01-04  Martin Jambor  <mjambor@suse.cz>
 
        PR tree-optimization/42398
index 867e15c..b96d091 100644 (file)
@@ -256,7 +256,7 @@ delete_coalesce_list (coalesce_list_p cl)
 static coalesce_pair_p
 find_coalesce_pair (coalesce_list_p cl, int p1, int p2, bool create)
 {
-  struct coalesce_pair p, *pair;
+  struct coalesce_pair p;
   void **slot;
   unsigned int hash;
 
@@ -272,22 +272,23 @@ find_coalesce_pair (coalesce_list_p cl, int p1, int p2, bool create)
       p.second_element = p2;
     }
 
-
   hash = coalesce_pair_map_hash (&p);
-  pair = (struct coalesce_pair *) htab_find_with_hash (cl->list, &p, hash);
+  slot = htab_find_slot_with_hash (cl->list, &p, hash,
+                                  create ? INSERT : NO_INSERT);
+  if (!slot)
+    return NULL;
 
-  if (create && !pair)
+  if (!*slot)
     {
+      struct coalesce_pair * pair = XNEW (struct coalesce_pair);
       gcc_assert (cl->sorted == NULL);
-      pair = XNEW (struct coalesce_pair);
       pair->first_element = p.first_element;
       pair->second_element = p.second_element;
       pair->cost = 0;
-      slot = htab_find_slot_with_hash (cl->list, pair, hash, INSERT);
-      *(struct coalesce_pair **)slot = pair;
+      *slot = (void *)pair;
     }
 
-  return pair;
+  return (struct coalesce_pair *) *slot;
 }
 
 static inline void
index 48f423b..bbe4539 100644 (file)
@@ -2229,50 +2229,47 @@ lookup_avail_expr (gimple stmt, bool insert)
   void **slot;
   tree lhs;
   tree temp;
-  struct expr_hash_elt *element = XNEW (struct expr_hash_elt);
+  struct expr_hash_elt element;
 
   /* Get LHS of assignment or call, else NULL_TREE.  */
   lhs = gimple_get_lhs (stmt);
 
-  initialize_hash_element (stmt, lhs, element);
+  initialize_hash_element (stmt, lhs, &element);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "LKUP ");
-      print_expr_hash_elt (dump_file, element);
+      print_expr_hash_elt (dump_file, &element);
     }
 
   /* Don't bother remembering constant assignments and copy operations.
      Constants and copy operations are handled by the constant/copy propagator
      in optimize_stmt.  */
-  if (element->expr.kind == EXPR_SINGLE
-      && (TREE_CODE (element->expr.ops.single.rhs) == SSA_NAME
-          || is_gimple_min_invariant (element->expr.ops.single.rhs)))
-    {
-      free (element);
-      return NULL_TREE;
-    }
+  if (element.expr.kind == EXPR_SINGLE
+      && (TREE_CODE (element.expr.ops.single.rhs) == SSA_NAME
+          || is_gimple_min_invariant (element.expr.ops.single.rhs)))
+    return NULL_TREE;
 
   /* Finally try to find the expression in the main expression hash table.  */
-  slot = htab_find_slot_with_hash (avail_exprs, element, element->hash,
+  slot = htab_find_slot_with_hash (avail_exprs, &element, element.hash,
                                   (insert ? INSERT : NO_INSERT));
   if (slot == NULL)
-    {
-      free (element);
-      return NULL_TREE;
-    }
+    return NULL_TREE;
 
   if (*slot == NULL)
     {
-      *slot = (void *) element;
+      struct expr_hash_elt *element2 = XNEW (struct expr_hash_elt);
+      *element2 = element;
+      element2->stamp = element2;
+      *slot = (void *) element2;
 
       if (dump_file && (dump_flags & TDF_DETAILS))
         {
           fprintf (dump_file, "2>>> ");
-          print_expr_hash_elt (dump_file, element);
+          print_expr_hash_elt (dump_file, element2);
         }
 
-      VEC_safe_push (expr_hash_elt_t, heap, avail_exprs_stack, element);
+      VEC_safe_push (expr_hash_elt_t, heap, avail_exprs_stack, element2);
       return NULL_TREE;
     }
 
@@ -2289,8 +2286,6 @@ lookup_avail_expr (gimple stmt, bool insert)
        lhs = temp;
     }
 
-  free (element);
-
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "FIND: ");
index 3087fe3..8296442 100644 (file)
@@ -684,7 +684,10 @@ sorted_array_from_bitmap_set (bitmap_set_t set)
 {
   unsigned int i, j;
   bitmap_iterator bi, bj;
-  VEC(pre_expr, heap) *result = NULL;
+  VEC(pre_expr, heap) *result;
+
+  /* Pre-allocate roughly enough space for the array.  */
+  result = VEC_alloc (pre_expr, heap, bitmap_count_bits (set->values));
 
   FOR_EACH_VALUE_ID_IN_SET (set, i, bi)
     {
@@ -1446,6 +1449,10 @@ phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
   if (!expr)
     return NULL;
 
+  /* Constants contain no values that need translation.  */
+  if (expr->kind == CONSTANT)
+    return expr;
+
   if (value_id_constant_p (get_expr_value_id (expr)))
     return expr;
 
@@ -1455,10 +1462,6 @@ phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
 
   switch (expr->kind)
     {
-      /* Constants contain no values that need translation.  */
-    case CONSTANT:
-      return expr;
-
     case NARY:
       {
        unsigned int i;
index 2994bff..79ce3c2 100644 (file)
@@ -357,21 +357,23 @@ unsigned int
 get_or_alloc_constant_value_id (tree constant)
 {
   void **slot;
-  vn_constant_t vc = XNEW (struct vn_constant_s);
+  struct vn_constant_s vc;
+  vn_constant_t vcp;
 
-  vc->hashcode = vn_hash_constant_with_type (constant);
-  vc->constant = constant;
-  slot = htab_find_slot_with_hash (constant_to_value_id, vc,
-                                  vc->hashcode, INSERT);
+  vc.hashcode = vn_hash_constant_with_type (constant);
+  vc.constant = constant;
+  slot = htab_find_slot_with_hash (constant_to_value_id, &vc,
+                                  vc.hashcode, INSERT);
   if (*slot)
-    {
-      free (vc);
-      return ((vn_constant_t)*slot)->value_id;
-    }
-  vc->value_id = get_next_value_id ();
-  *slot = vc;
-  bitmap_set_bit (constant_value_ids, vc->value_id);
-  return vc->value_id;
+    return ((vn_constant_t)*slot)->value_id;
+
+  vcp = XNEW (struct vn_constant_s);
+  vcp->hashcode = vc.hashcode;
+  vcp->constant = constant;
+  vcp->value_id = get_next_value_id ();
+  *slot = (void *) vcp;
+  bitmap_set_bit (constant_value_ids, vcp->value_id);
+  return vcp->value_id;
 }
 
 /* Return true if V is a value id for a constant.  */