[new-ra] Don't go wild when splitting webs

Michael Matz matz@suse.de
Mon Oct 13 12:59:00 GMT 2003


Hi,

noticed with --enable-checking.  With that the functions in insn-recog.c
and insn-attrtab.c become unbearable slow to compiler.  They have about
18000 pseudos up to 63000 pseudos, and the slow code for building the
containement graph doesn't deal very well with that (it isn't incremental
yet).  Compiling insn-recog.c took about 50 minutes on a fast machine ;-)

Now it's better.  Bootstrapped on x86, all languages.


Ciao,
Michael.
-- 
        * ra.c (flag_ra_split_webs): New.
        (free_mem): Use it.
        (reg_alloc): Set it (with cutoff).
        * ra.h (flag_ra_split_webs): Declare.
        * ra-rewrite.c (actual_spill): Use it.
        * ra-colorize.c (colorize_one_web, try_recolor_web, check_colors,
        ra_colorize_graph): Ditto.

Index: ra-colorize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-colorize.c,v
retrieving revision 1.1.2.17
diff -u -p -r1.1.2.17 ra-colorize.c
--- ra-colorize.c	10 Oct 2003 14:18:59 -0000	1.1.2.17
+++ ra-colorize.c	13 Oct 2003 12:47:30 -0000
@@ -1721,7 +1721,8 @@ colorize_one_web (struct web *web, int h
 				    "  to spill %d was a good idea\n",
 				    try->id);
 		      remove_list (try->dlink, &WEBS(SPILLED));
-		      unsplit_web (try);
+		      if (flag_ra_split_webs)
+			unsplit_web (try);
 		      if (try->was_spilled)
 			colorize_one_web (try, 0);
 		      else
@@ -1773,7 +1774,7 @@ colorize_one_web (struct web *web, int h
       web->color = -1;
     }
   /* Try to split WEB, but only if we didn't find _any_ color for us.  */
-  if (web->type == SPILLED && bestc < 0)
+  if (flag_ra_split_webs && web->type == SPILLED && bestc < 0)
     find_splits (web);
 }

@@ -1963,7 +1964,8 @@ try_recolor_web (struct web *web)
 	      /* Allow webs to be spilled.  */
 	      if (web2->spill_temp == 0 || web2->spill_temp == 2)
 		web2->was_spilled = 1;
-	      unsplit_web (web2);
+	      if (flag_ra_split_webs)
+		unsplit_web (web2);
 	      colorize_one_web (web2, 1);
 	      if (web2->type == SPILLED)
 		cost += web2->spill_cost;
@@ -2189,8 +2191,9 @@ check_colors (void)
 	    if (aweb->color >= web2->color + nregs2
 	        || web2->color >= aweb->color + nregs)
 	      continue;
-	    if (bitmap_bit_p (split_around[aweb->id], web2->id)
-		|| bitmap_bit_p (split_around[web2->id], aweb->id))
+	    if (flag_ra_split_webs
+		&& (bitmap_bit_p (split_around[aweb->id], web2->id)
+		    || bitmap_bit_p (split_around[web2->id], aweb->id)))
 	      continue;
 	    /*abort ();*/
 	  }
@@ -2216,8 +2219,10 @@ check_colors (void)
 		if ((tcol + tofs >= scol + sofs + ssize)
 		    || (scol + sofs >= tcol + tofs + tsize))
 		  continue;
-		if (bitmap_bit_p (split_around[aweb->id], alias(wl->t)->id)
-		    || bitmap_bit_p (split_around[alias (wl->t)->id], aweb->id))
+		if (flag_ra_split_webs
+		    && (bitmap_bit_p (split_around[aweb->id], alias(wl->t)->id)
+			|| bitmap_bit_p (split_around[alias (wl->t)->id],
+					 aweb->id)))
 		  continue;
 		/*abort ();*/
 	      }
@@ -3103,7 +3108,8 @@ ra_colorize_graph (struct df *df)
       extended_coalesce_2 ();
     }

-  init_split_costs ();
+  if (flag_ra_split_webs)
+    init_split_costs ();

   /* Now build the select stack.  */
   do
Index: ra-rewrite.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-rewrite.c,v
retrieving revision 1.1.2.21
diff -u -p -r1.1.2.21 ra-rewrite.c
--- ra-rewrite.c	10 Oct 2003 14:19:00 -0000	1.1.2.21
+++ ra-rewrite.c	13 Oct 2003 12:47:30 -0000
@@ -2151,7 +2151,8 @@ actual_spill (int spill_p ATTRIBUTE_UNUS
   delete_useless_defs ();
   BITMAP_XFREE (useless_defs);
   split_webs = BITMAP_XMALLOC ();
-  insert_splits (new_deaths);
+  if (flag_ra_split_webs)
+    insert_splits (new_deaths);
   sbitmap_free (insns_with_deaths);
   insns_with_deaths = sbitmap_alloc (get_max_uid ());
   death_insns_max_uid = get_max_uid ();
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.1.2.73
diff -u -p -r1.1.2.73 ra.c
--- ra.c	10 Oct 2003 14:39:06 -0000	1.1.2.73
+++ ra.c	13 Oct 2003 12:47:30 -0000
@@ -173,6 +173,7 @@ int flag_ra_dump_only_costs = 0;
 int flag_ra_biased = 0;
 int flag_ra_improved_spilling = 0;
 int flag_ra_ir_spilling = 0;
+int flag_ra_split_webs = 0;
 int flag_ra_optimistic_coalescing = 0;
 int flag_ra_break_aliases = 0;
 int flag_ra_merge_spill_costs = 0;
@@ -425,7 +426,8 @@ free_mem (struct df *df ATTRIBUTE_UNUSED
 {
   free_insn_info ();
   ra_build_free ();
-  free_split_costs ();
+  if (flag_ra_split_webs)
+    free_split_costs ();
 }

 /* Free all memory allocated for the register allocator.  Used, when
@@ -995,12 +997,17 @@ reg_alloc (void)
   flag_ra_spill_every_use = 0;
   flag_ra_improved_spilling = 1;
   flag_ra_ir_spilling = 0;
+  flag_ra_split_webs = 1;
   flag_ra_break_aliases = 0;
   flag_ra_optimistic_coalescing = 1;
   flag_ra_merge_spill_costs = 1;
   if (flag_ra_optimistic_coalescing)
     flag_ra_break_aliases = 1;
   flag_ra_dump_notes = 0;
+  if (max_reg_num () > 9000)
+    flag_ra_split_webs = 0;
+  if (flag_ra_ir_spilling && flag_ra_split_webs)
+    abort ();
   make_insns_structurally_valid ();

   /* Allocate the global df structure.  */
Index: ra.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.h,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 ra.h
--- ra.h	10 Oct 2003 14:19:00 -0000	1.1.2.11
+++ ra.h	13 Oct 2003 12:47:30 -0000
@@ -565,6 +565,8 @@ extern int flag_ra_improved_spilling;
    Chaintin style spilling (only at deaths).  */
 extern int flag_ra_ir_spilling;

+extern int flag_ra_split_webs;
+
 /* Nonzero if we use optimistic coalescing, zero for iterated
    coalescing.  */
 extern int flag_ra_optimistic_coalescing;



More information about the Gcc-patches mailing list