This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pretty-ipa] Better costs for EH edges in out-of-ssa


Hi,
currently out-of-ssa actually preffers outputing compensation on EH
edges because they are unlikely.  This bloats code size since splitting
EH edge might need new landing pad.

This patch makes costs more realistic and on tramp3d we now no longer
produce new EH handlers during out-of-ssa.

Bootstrapped/regtested x86_64-linux
	* tree-ssa-coalesce.c (coalesce_cost): Do not take ciritical
	parameter; update callers.
	(coalesce_cost_edge): EH edges are costier because they needs splitting
	even if not critical and even more costier when there are multiple
	EH predecestors.
Index: tree-ssa-coalesce.c
===================================================================
--- tree-ssa-coalesce.c	(revision 145766)
+++ tree-ssa-coalesce.c	(working copy)
@@ -71,11 +71,10 @@
 #define MUST_COALESCE_COST	INT_MAX
 
 
-/* Return cost of execution of copy instruction with FREQUENCY
-   possibly on CRITICAL edge and in HOT basic block.  */
+/* Return cost of execution of copy instruction with FREQUENCY.  */
 
 static inline int
-coalesce_cost (int frequency, bool optimize_for_size, bool critical)
+coalesce_cost (int frequency, bool optimize_for_size)
 {
   /* Base costs on BB frequencies bounded by 1.  */
   int cost = frequency;
@@ -86,9 +85,6 @@
   if (optimize_for_size)
     cost = 1;
 
-  /* Inserting copy on critical edge costs more than inserting it elsewhere.  */
-  if (critical)
-    cost *= 2;
   return cost;
 }
 
@@ -98,7 +94,7 @@
 static inline int 
 coalesce_cost_bb (basic_block bb)
 {
-  return coalesce_cost (bb->frequency, optimize_bb_for_size_p (bb), false);
+  return coalesce_cost (bb->frequency, optimize_bb_for_size_p (bb));
 }
 
 
@@ -107,12 +103,38 @@
 static inline int 
 coalesce_cost_edge (edge e)
 {
+  int mult = 1;
+
+  /* Inserting copy on critical edge costs more than inserting it elsewhere.  */
+  if (EDGE_CRITICAL_P (e))
+    mult = 2;
   if (e->flags & EDGE_ABNORMAL)
     return MUST_COALESCE_COST;
+  if (e->flags & EDGE_EH)
+    {
+      edge e2;
+      edge_iterator ei;
+      FOR_EACH_EDGE (e2, ei, e->dest->preds)
+	if (e2 != e)
+	  {
+	    /* Putting code on EH edge that leads to BB
+	       with multiple predecestors imply splitting of
+	       edge too.  */
+	    if (mult < 2)
+	      mult = 2;
+	    /* If there are multiple EH predecestors, we
+	       also copy EH regions and produce separate
+	       landing pad.  This is expensive.  */
+	    if (e2->flags & EDGE_EH)
+	      {
+	        mult = 5;
+	        break;
+	      }
+	  }
+    }
 
   return coalesce_cost (EDGE_FREQUENCY (e), 
-			optimize_edge_for_size_p (e), 
-			EDGE_CRITICAL_P (e));
+			optimize_edge_for_size_p (e)) * mult;
 }
 
 
@@ -1094,8 +1116,7 @@
 		    if (SSA_NAME_VAR (outputs[match]) == SSA_NAME_VAR (input))
 		      {
 			cost = coalesce_cost (REG_BR_PROB_BASE, 
-					      optimize_bb_for_size_p (bb),
-					      false);
+					      optimize_bb_for_size_p (bb));
 			add_coalesce (cl, v1, v2, cost);
 			bitmap_set_bit (used_in_copy, v1);
 			bitmap_set_bit (used_in_copy, v2);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]