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]

RFA: patch to solve spec2006 degradation reported in 37243


The following patch solves SPEC2006 degradation reported in PR37243.
The analysis of the problem can be found in

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37243

The patch was successfully bootstrapped and tested on x86_64.

2008-08-30 Vladimir Makarov <vmakarov@redhat.com>

PR rtl-opt/37243

   * ira-int.h (ira_loop_tree_node): Rename mentioned_allocnos to
   all_allocnos.

   * ira-color.c (print_loop_title): Use all_allocnos.
   (color_pass): Ditto.  Don't add border_allocnos.  Check that
   subloop allocno in the correspdoning bitmap all_allocnos.

* ira-emit.c (change_loop): Use all_allocnos.

* ira-build.c (create_loop_tree_nodes, finish_loop_tree_node):
Ditto.
(ira_create_allocno): Set up all_allocnos bit for the created
allocno.
(create_cap_allocno): Remove setting mentioned_allocnos.
(create_insn_allocnos): Ditto.
(remove_unnecessary_allocnos): Use all_allocnos.
(check_allocno_creation): Check that allocnos are in the
corresponding bitmap all_allocnos.


Index: ira-int.h
===================================================================
--- ira-int.h	(revision 139597)
+++ ira-int.h	(working copy)
@@ -111,16 +111,17 @@ struct ira_loop_tree_node
      (defined only for the cover classes).  */
   int reg_pressure[N_REG_CLASSES];
 
-  /* Numbers of allocnos referred in the loop node.  */
-  bitmap mentioned_allocnos;
+  /* Numbers of allocnos referred or living in the loop node (except
+     for its subloops).  */
+  bitmap all_allocnos;
+
+  /* Numbers of allocnos living at the loop borders.  */
+  bitmap border_allocnos;
 
   /* Regnos of pseudos modified in the loop node (including its
      subloops).  */
   bitmap modified_regnos;
 
-  /* Numbers of allocnos living at the loop borders.  */
-  bitmap border_allocnos;
-
   /* Numbers of copies referred in the corresponding loop.  */
   bitmap local_copies;
 };
Index: ira-color.c
===================================================================
--- ira-color.c	(revision 139770)
+++ ira-color.c	(working copy)
@@ -1534,13 +1606,13 @@ print_loop_title (ira_loop_tree_node_t l
 
   ira_assert (loop_tree_node->loop != NULL);
   fprintf (ira_dump_file,
-	   "\n  Loop %d (parent %d, header bb%d, depth %d)\n    ref:",
+	   "\n  Loop %d (parent %d, header bb%d, depth %d)\n    all:",
 	   loop_tree_node->loop->num,
 	   (loop_tree_node->parent == NULL
 	    ? -1 : loop_tree_node->parent->loop->num),
 	   loop_tree_node->loop->header->index,
 	   loop_depth (loop_tree_node->loop));
-  EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->mentioned_allocnos, 0, j, bi)
+  EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->all_allocnos, 0, j, bi)
     fprintf (ira_dump_file, " %dr%d", j, ALLOCNO_REGNO (ira_allocnos[j]));
   fprintf (ira_dump_file, "\n    modified regnos:");
   EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->modified_regnos, 0, j, bi)
@@ -1582,8 +1654,7 @@ color_pass (ira_loop_tree_node_t loop_tr
   if (internal_flag_ira_verbose > 1 && ira_dump_file != NULL)
     print_loop_title (loop_tree_node);
 
-  bitmap_copy (coloring_allocno_bitmap, loop_tree_node->mentioned_allocnos);
-  bitmap_ior_into (coloring_allocno_bitmap, loop_tree_node->border_allocnos);
+  bitmap_copy (coloring_allocno_bitmap, loop_tree_node->all_allocnos);
   bitmap_copy (consideration_allocno_bitmap, coloring_allocno_bitmap);
   EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, j, bi)
     {
@@ -1597,7 +1668,7 @@ color_pass (ira_loop_tree_node_t loop_tr
   /* Process caps.  They are processed just once.  */
   if (flag_ira_algorithm == IRA_ALGORITHM_MIXED
       || flag_ira_algorithm == IRA_ALGORITHM_REGIONAL)
-    EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->mentioned_allocnos, 0, j, bi)
+    EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->all_allocnos, 0, j, bi)
       {
 	a = ira_allocnos[j];
 	if (ALLOCNO_CAP_MEMBER (a) == NULL)
@@ -1653,12 +1724,11 @@ color_pass (ira_loop_tree_node_t loop_tr
 	  if (subloop_allocno == NULL
 	      || ALLOCNO_CAP (subloop_allocno) != NULL)
 	    continue;
-	  if ((flag_ira_algorithm == IRA_ALGORITHM_MIXED
-	       && (loop_tree_node->reg_pressure[rclass]
-		   <= ira_available_class_regs[rclass]))
-	      || (hard_regno < 0
-		  && ! bitmap_bit_p (subloop_node->mentioned_allocnos,
-				     ALLOCNO_NUM (subloop_allocno))))
+	  ira_assert (bitmap_bit_p (subloop_node->all_allocnos,
+				    ALLOCNO_NUM (subloop_allocno)));
+	  if (flag_ira_algorithm == IRA_ALGORITHM_MIXED
+	      && (loop_tree_node->reg_pressure[rclass]
+		  <= ira_available_class_regs[rclass]))
 	    {
 	      if (! ALLOCNO_ASSIGNED_P (subloop_allocno))
 		{
Index: ira-emit.c
===================================================================
--- ira-emit.c	(revision 139597)
+++ ira-emit.c	(working copy)
@@ -424,7 +424,7 @@ change_loop (ira_loop_tree_node_t node)
      might get the different hard register.  So we need to change
      ALLOCNO_REG.  */
   bitmap_and_compl (local_allocno_bitmap,
-		    ira_curr_loop_tree_node->mentioned_allocnos,
+		    ira_curr_loop_tree_node->all_allocnos,
 		    ira_curr_loop_tree_node->border_allocnos);
   EXECUTE_IF_SET_IN_REG_SET (local_allocno_bitmap, 0, i, bi)
     {
Index: ira-build.c
===================================================================
--- ira-build.c	(revision 139597)
+++ ira-build.c	(working copy)
@@ -113,7 +113,7 @@ create_loop_tree_nodes (bool loops_p)
       ira_bb_nodes[i].regno_allocno_map = NULL;
       memset (ira_bb_nodes[i].reg_pressure, 0,
 	      sizeof (ira_bb_nodes[i].reg_pressure));
-      ira_bb_nodes[i].mentioned_allocnos = NULL;
+      ira_bb_nodes[i].all_allocnos = NULL;
       ira_bb_nodes[i].modified_regnos = NULL;
       ira_bb_nodes[i].border_allocnos = NULL;
       ira_bb_nodes[i].local_copies = NULL;
@@ -156,7 +156,7 @@ create_loop_tree_nodes (bool loops_p)
 	      sizeof (ira_allocno_t) * max_regno);
       memset (ira_loop_nodes[i].reg_pressure, 0,
 	      sizeof (ira_loop_nodes[i].reg_pressure));
-      ira_loop_nodes[i].mentioned_allocnos = ira_allocate_bitmap ();
+      ira_loop_nodes[i].all_allocnos = ira_allocate_bitmap ();
       ira_loop_nodes[i].modified_regnos = ira_allocate_bitmap ();
       ira_loop_nodes[i].border_allocnos = ira_allocate_bitmap ();
       ira_loop_nodes[i].local_copies = ira_allocate_bitmap ();
@@ -188,7 +188,7 @@ finish_loop_tree_node (ira_loop_tree_nod
       ira_free_bitmap (loop->local_copies);
       ira_free_bitmap (loop->border_allocnos);
       ira_free_bitmap (loop->modified_regnos);
-      ira_free_bitmap (loop->mentioned_allocnos);
+      ira_free_bitmap (loop->all_allocnos);
       ira_free (loop->regno_allocno_map);
       loop->regno_allocno_map = NULL;
     }
@@ -212,8 +212,8 @@ finish_loop_tree_nodes (void)
 	ira_free_bitmap (ira_bb_nodes[i].border_allocnos);
       if (ira_bb_nodes[i].modified_regnos != NULL)
 	ira_free_bitmap (ira_bb_nodes[i].modified_regnos);
-      if (ira_bb_nodes[i].mentioned_allocnos != NULL)
-	ira_free_bitmap (ira_bb_nodes[i].mentioned_allocnos);
+      if (ira_bb_nodes[i].all_allocnos != NULL)
+	ira_free_bitmap (ira_bb_nodes[i].all_allocnos);
       if (ira_bb_nodes[i].regno_allocno_map != NULL)
 	ira_free (ira_bb_nodes[i].regno_allocno_map);
     }
@@ -437,6 +437,7 @@ ira_create_allocno (int regno, bool cap_
   ALLOCNO_CAP (a) = NULL;
   ALLOCNO_CAP_MEMBER (a) = NULL;
   ALLOCNO_NUM (a) = ira_allocnos_num;
+  bitmap_set_bit (loop_tree_node->all_allocnos, ALLOCNO_NUM (a));
   ALLOCNO_CONFLICT_ALLOCNO_ARRAY (a) = NULL;
   ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0;
   COPY_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), ira_no_alloc_regs);
@@ -765,7 +766,6 @@ create_cap_allocno (ira_allocno_t a)
   ira_set_allocno_cover_class (cap, cover_class);
   ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a);
   ALLOCNO_CAP_MEMBER (cap) = a;
-  bitmap_set_bit (parent->mentioned_allocnos, ALLOCNO_NUM (cap));
   ALLOCNO_CAP (a) = cap;
   ALLOCNO_COVER_CLASS_COST (cap) = ALLOCNO_COVER_CLASS_COST (a);
   ALLOCNO_MEMORY_COST (cap) = ALLOCNO_MEMORY_COST (a);
@@ -1290,8 +1290,6 @@ create_insn_allocnos (rtx x, bool output
 	  
 	  ALLOCNO_NREFS (a)++;
 	  ALLOCNO_FREQ (a) += REG_FREQ_FROM_BB (curr_bb);
-	  bitmap_set_bit (ira_curr_loop_tree_node->mentioned_allocnos,
-			  ALLOCNO_NUM (a));
 	  if (output_p)
 	    bitmap_set_bit (ira_curr_loop_tree_node->modified_regnos, regno);
 	}
@@ -1709,7 +1707,7 @@ remove_unnecessary_allocnos (void)
 		prev_a = a;
 		ALLOCNO_LOOP_TREE_NODE (a) = parent;
 		parent->regno_allocno_map[regno] = a;
-		bitmap_set_bit (parent->mentioned_allocnos, ALLOCNO_NUM (a));
+		bitmap_set_bit (parent->all_allocnos, ALLOCNO_NUM (a));
 	      }
 	    else
 	      {
@@ -2358,20 +2356,18 @@ check_allocno_creation (void)
 
   FOR_EACH_ALLOCNO (a, ai)
     {
-      if (ALLOCNO_LOOP_TREE_NODE (a) == ira_loop_tree_root)
+      loop_tree_node = ALLOCNO_LOOP_TREE_NODE (a);
+      ira_assert (bitmap_bit_p (loop_tree_node->all_allocnos,
+				ALLOCNO_NUM (a)));
+      if (loop_tree_node == ira_loop_tree_root)
 	continue;
       if (ALLOCNO_CAP_MEMBER (a) != NULL)
-	{
-	  ira_assert (ALLOCNO_CAP (a) != NULL);
-	}
+	ira_assert (ALLOCNO_CAP (a) != NULL);
       else if (ALLOCNO_CAP (a) == NULL)
-	{
-	  loop_tree_node = ALLOCNO_LOOP_TREE_NODE (a);
-	  ira_assert (loop_tree_node->parent
-		      ->regno_allocno_map[ALLOCNO_REGNO (a)] != NULL
-		      && bitmap_bit_p (loop_tree_node->border_allocnos,
-				       ALLOCNO_NUM (a)));
-	}
+	ira_assert (loop_tree_node->parent
+		    ->regno_allocno_map[ALLOCNO_REGNO (a)] != NULL
+		    && bitmap_bit_p (loop_tree_node->border_allocnos,
+				     ALLOCNO_NUM (a)));
     }
 }
 #endif

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