OSDN Git Service

PR testsuite/20772
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-live.c
index 180916d..132af92 100644 (file)
@@ -341,18 +341,15 @@ create_ssa_var_map (int flags)
   var_map map;
   ssa_op_iter iter;
 #ifdef ENABLE_CHECKING
-  sbitmap used_in_real_ops;
-  sbitmap used_in_virtual_ops;
+  bitmap used_in_real_ops;
+  bitmap used_in_virtual_ops;
 #endif
 
   map = init_var_map (num_ssa_names + 1);
 
 #ifdef ENABLE_CHECKING
-  used_in_real_ops = sbitmap_alloc (num_referenced_vars);
-  sbitmap_zero (used_in_real_ops);
-
-  used_in_virtual_ops = sbitmap_alloc (num_referenced_vars);
-  sbitmap_zero (used_in_virtual_ops);
+  used_in_real_ops = BITMAP_ALLOC (NULL);
+  used_in_virtual_ops = BITMAP_ALLOC (NULL);
 #endif
 
   if (flags & SSA_VAR_MAP_REF_COUNT)
@@ -389,7 +386,7 @@ create_ssa_var_map (int flags)
              register_ssa_partition (map, use, true);
 
 #ifdef ENABLE_CHECKING
-             SET_BIT (used_in_real_ops, var_ann (SSA_NAME_VAR (use))->uid);
+             bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (use)));
 #endif
            }
 
@@ -398,7 +395,7 @@ create_ssa_var_map (int flags)
              register_ssa_partition (map, dest, false);
 
 #ifdef ENABLE_CHECKING
-             SET_BIT (used_in_real_ops, var_ann (SSA_NAME_VAR (dest))->uid);
+             bitmap_set_bit (used_in_real_ops, DECL_UID (SSA_NAME_VAR (dest)));
 #endif
            }
 
@@ -407,7 +404,8 @@ create_ssa_var_map (int flags)
          FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, 
                                     SSA_OP_VIRTUAL_USES | SSA_OP_VMUSTDEF)
            {
-             SET_BIT (used_in_virtual_ops, var_ann (SSA_NAME_VAR (use))->uid);
+             bitmap_set_bit (used_in_virtual_ops, 
+                             DECL_UID (SSA_NAME_VAR (use)));
            }
 
 #endif /* ENABLE_CHECKING */
@@ -419,21 +417,21 @@ create_ssa_var_map (int flags)
 #if defined ENABLE_CHECKING
   {
     unsigned i;
-    sbitmap both = sbitmap_alloc (num_referenced_vars);
-    sbitmap_a_and_b (both, used_in_real_ops, used_in_virtual_ops);
-    if (sbitmap_first_set_bit (both) >= 0)
+    bitmap both = BITMAP_ALLOC (NULL);
+    bitmap_and (both, used_in_real_ops, used_in_virtual_ops);
+    if (!bitmap_empty_p (both))
       {
-       sbitmap_iterator sbi;
+       bitmap_iterator bi;
 
-       EXECUTE_IF_SET_IN_SBITMAP (both, 0, i, sbi)
+       EXECUTE_IF_SET_IN_BITMAP (both, 0, i, bi)
          fprintf (stderr, "Variable %s used in real and virtual operands\n",
                   get_name (referenced_var (i)));
        internal_error ("SSA corruption");
       }
 
-    sbitmap_free (used_in_real_ops);
-    sbitmap_free (used_in_virtual_ops);
-    sbitmap_free (both);
+    BITMAP_FREE (used_in_real_ops);
+    BITMAP_FREE (used_in_virtual_ops);
+    BITMAP_FREE (both);
   }
 #endif
 
@@ -1147,11 +1145,30 @@ find_partition_pair (coalesce_list_p cl, int p1, int p2, bool create)
   return node;
 }
 
+/* Return cost of execution of copy instruction with FREQUENCY
+   possibly on CRITICAL edge and in HOT basic block.  */
+int
+coalesce_cost (int frequency, bool hot, bool critical)
+{
+  /* Base costs on BB frequencies bounded by 1.  */
+  int cost = frequency;
+
+  if (!cost)
+    cost = 1;
+  if (optimize_size || hot)
+    cost = 1;
+  /* Inserting copy on critical edge costs more
+     than inserting it elsewhere.  */
+  if (critical)
+    cost *= 2;
+  return cost;
+}
 
 /* Add a potential coalesce between P1 and P2 in CL with a cost of VALUE.  */
 
 void 
-add_coalesce (coalesce_list_p cl, int p1, int p2, int value)
+add_coalesce (coalesce_list_p cl, int p1, int p2,
+             int value)
 {
   partition_pair_p node;
 
@@ -1385,7 +1402,9 @@ build_tree_conflict_graph (tree_live_info_p liveinfo, tpa_p tpa,
                  if (bit)
                    bitmap_set_bit (live, p2);
                  if (cl)
-                   add_coalesce (cl, p1, p2, 1);
+                   add_coalesce (cl, p1, p2,
+                                 coalesce_cost (bb->frequency,
+                                                maybe_hot_bb_p (bb), false));
                  set_if_valid (map, live, rhs);
                }
            }