tree-outof-ssa.c (coalesce_ssa_name): Use coalesce_cost.
authorJan Hubicka <jh@suse.cz>
Sat, 30 Jul 2005 22:14:17 +0000 (00:14 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 30 Jul 2005 22:14:17 +0000 (22:14 +0000)
* tree-outof-ssa.c (coalesce_ssa_name): Use coalesce_cost.
(coalesce_vars): Likewise.
* tree-ssa-live.c (coalesce_cost): New.
(build_tree_conflict_graph): Use coalesce_cost.
* tree-ssa-live.h (coalesce_cost): Declare.

From-SVN: r102593

gcc/ChangeLog
gcc/tree-outof-ssa.c
gcc/tree-ssa-live.c
gcc/tree-ssa-live.h

index 59e5c838248c32d393cfc9b8eb7ee184a3c6039c..a2c7bdc02729c1f3971ee69a88bc58222b5394c3 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-31  Jan Hubicka  <jh@suse.cz>
+
+       * tree-outof-ssa.c (coalesce_ssa_name): Use coalesce_cost.
+       (coalesce_vars): Likewise.
+       * tree-ssa-live.c (coalesce_cost): New.
+       (build_tree_conflict_graph): Use coalesce_cost.
+       * tree-ssa-live.h (coalesce_cost): Declare.
+
 2005-07-30  Richard Earnshaw  <richard.earnshaw@arm.com>
 
        * arm.md (all peepholes for post-increment operations): Delete.
index 38f583e7112c52e8a5aa004273bacf0282faed39..b8ceaa85cd41d0ea201fbb6ef296ef23a7a44a5c 100644 (file)
@@ -729,7 +729,13 @@ coalesce_ssa_name (var_map map, int flags)
                continue;
              p2 = var_to_partition (map, PHI_ARG_DEF (phi, x));
              if (p2 != NO_PARTITION)
-               add_coalesce (cl, p, p2, 1);
+               {
+                 edge e = PHI_ARG_EDGE (phi, x);
+                 add_coalesce (cl, p, p2,
+                               coalesce_cost (EDGE_FREQUENCY (e),
+                                              maybe_hot_bb_p (bb),
+                                              EDGE_CRITICAL_P (e)));
+               }
            }
        }
     }
@@ -748,7 +754,10 @@ coalesce_ssa_name (var_map map, int flags)
              i = x;
            }
          else
-           add_coalesce (cl, i, x, 1);
+           add_coalesce (cl, i, x,
+                         coalesce_cost (EXIT_BLOCK_PTR->frequency,
+                                        maybe_hot_bb_p (EXIT_BLOCK_PTR),
+                                        false));
        }
     }
 
@@ -1097,7 +1106,14 @@ coalesce_vars (var_map map, tree_live_info_p liveinfo)
              if (p2 == (unsigned)NO_PARTITION)
                continue;
              if (p != p2)
-               add_coalesce (cl, p, p2, 1);
+               {
+                 edge e = PHI_ARG_EDGE (phi, x);
+
+                 add_coalesce (cl, p, p2, 
+                               coalesce_cost (EDGE_FREQUENCY (e),
+                                              maybe_hot_bb_p (bb),
+                                              EDGE_CRITICAL_P (e)));
+               }
            }
        }
    }
index 1647292b5e6d727896f3a7e148bad4c3113d7dbc..132af929852e8ba4b33a55e85279f0f8214adc78 100644 (file)
@@ -1145,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;
 
@@ -1383,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);
                }
            }
index d8711c0f419ebb27db5161e092f53620c4adcd2b..2c4127402fab6f9e4dd9e1ef3b17a0196ba71caa 100644 (file)
@@ -700,6 +700,7 @@ typedef struct coalesce_list_d
 
 extern coalesce_list_p create_coalesce_list (var_map);
 extern void add_coalesce (coalesce_list_p, int, int, int);
+extern int coalesce_cost (int, bool, bool);
 extern void sort_coalesce_list (coalesce_list_p);
 extern void dump_coalesce_list (FILE *, coalesce_list_p);
 extern void delete_coalesce_list (coalesce_list_p);