Commit 49d988e7 by Vladimir Makarov Committed by Vladimir Makarov

re PR middle-end/37243 (IRA causes wrong code generation)

2008-09-03  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.

From-SVN: r139952
parent 27738602
...@@ -7,6 +7,29 @@ ...@@ -7,6 +7,29 @@
2008-09-03 Vladimir Makarov <vmakarov@redhat.com> 2008-09-03 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-opt/37243 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.
2008-09-03 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-opt/37243
* ira-conflicts.c (REG_SUBREG_P, go_through_subreg): New. * ira-conflicts.c (REG_SUBREG_P, go_through_subreg): New.
(process_regs_for_copy): Process subregs. Refine check when cost (process_regs_for_copy): Process subregs. Refine check when cost
......
...@@ -113,7 +113,7 @@ create_loop_tree_nodes (bool loops_p) ...@@ -113,7 +113,7 @@ create_loop_tree_nodes (bool loops_p)
ira_bb_nodes[i].regno_allocno_map = NULL; ira_bb_nodes[i].regno_allocno_map = NULL;
memset (ira_bb_nodes[i].reg_pressure, 0, memset (ira_bb_nodes[i].reg_pressure, 0,
sizeof (ira_bb_nodes[i].reg_pressure)); 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].modified_regnos = NULL;
ira_bb_nodes[i].border_allocnos = NULL; ira_bb_nodes[i].border_allocnos = NULL;
ira_bb_nodes[i].local_copies = NULL; ira_bb_nodes[i].local_copies = NULL;
...@@ -156,7 +156,7 @@ create_loop_tree_nodes (bool loops_p) ...@@ -156,7 +156,7 @@ create_loop_tree_nodes (bool loops_p)
sizeof (ira_allocno_t) * max_regno); sizeof (ira_allocno_t) * max_regno);
memset (ira_loop_nodes[i].reg_pressure, 0, memset (ira_loop_nodes[i].reg_pressure, 0,
sizeof (ira_loop_nodes[i].reg_pressure)); 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].modified_regnos = ira_allocate_bitmap ();
ira_loop_nodes[i].border_allocnos = ira_allocate_bitmap (); ira_loop_nodes[i].border_allocnos = ira_allocate_bitmap ();
ira_loop_nodes[i].local_copies = ira_allocate_bitmap (); ira_loop_nodes[i].local_copies = ira_allocate_bitmap ();
...@@ -188,7 +188,7 @@ finish_loop_tree_node (ira_loop_tree_node_t loop) ...@@ -188,7 +188,7 @@ finish_loop_tree_node (ira_loop_tree_node_t loop)
ira_free_bitmap (loop->local_copies); ira_free_bitmap (loop->local_copies);
ira_free_bitmap (loop->border_allocnos); ira_free_bitmap (loop->border_allocnos);
ira_free_bitmap (loop->modified_regnos); ira_free_bitmap (loop->modified_regnos);
ira_free_bitmap (loop->mentioned_allocnos); ira_free_bitmap (loop->all_allocnos);
ira_free (loop->regno_allocno_map); ira_free (loop->regno_allocno_map);
loop->regno_allocno_map = NULL; loop->regno_allocno_map = NULL;
} }
...@@ -212,8 +212,8 @@ finish_loop_tree_nodes (void) ...@@ -212,8 +212,8 @@ finish_loop_tree_nodes (void)
ira_free_bitmap (ira_bb_nodes[i].border_allocnos); ira_free_bitmap (ira_bb_nodes[i].border_allocnos);
if (ira_bb_nodes[i].modified_regnos != NULL) if (ira_bb_nodes[i].modified_regnos != NULL)
ira_free_bitmap (ira_bb_nodes[i].modified_regnos); ira_free_bitmap (ira_bb_nodes[i].modified_regnos);
if (ira_bb_nodes[i].mentioned_allocnos != NULL) if (ira_bb_nodes[i].all_allocnos != NULL)
ira_free_bitmap (ira_bb_nodes[i].mentioned_allocnos); ira_free_bitmap (ira_bb_nodes[i].all_allocnos);
if (ira_bb_nodes[i].regno_allocno_map != NULL) if (ira_bb_nodes[i].regno_allocno_map != NULL)
ira_free (ira_bb_nodes[i].regno_allocno_map); ira_free (ira_bb_nodes[i].regno_allocno_map);
} }
...@@ -437,6 +437,7 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node) ...@@ -437,6 +437,7 @@ ira_create_allocno (int regno, bool cap_p, ira_loop_tree_node_t loop_tree_node)
ALLOCNO_CAP (a) = NULL; ALLOCNO_CAP (a) = NULL;
ALLOCNO_CAP_MEMBER (a) = NULL; ALLOCNO_CAP_MEMBER (a) = NULL;
ALLOCNO_NUM (a) = ira_allocnos_num; 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_ALLOCNO_ARRAY (a) = NULL;
ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0; ALLOCNO_CONFLICT_ALLOCNOS_NUM (a) = 0;
COPY_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), ira_no_alloc_regs); COPY_HARD_REG_SET (ALLOCNO_CONFLICT_HARD_REGS (a), ira_no_alloc_regs);
...@@ -765,7 +766,6 @@ create_cap_allocno (ira_allocno_t a) ...@@ -765,7 +766,6 @@ create_cap_allocno (ira_allocno_t a)
ira_set_allocno_cover_class (cap, cover_class); ira_set_allocno_cover_class (cap, cover_class);
ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a); ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a);
ALLOCNO_CAP_MEMBER (cap) = a; ALLOCNO_CAP_MEMBER (cap) = a;
bitmap_set_bit (parent->mentioned_allocnos, ALLOCNO_NUM (cap));
ALLOCNO_CAP (a) = cap; ALLOCNO_CAP (a) = cap;
ALLOCNO_COVER_CLASS_COST (cap) = ALLOCNO_COVER_CLASS_COST (a); ALLOCNO_COVER_CLASS_COST (cap) = ALLOCNO_COVER_CLASS_COST (a);
ALLOCNO_MEMORY_COST (cap) = ALLOCNO_MEMORY_COST (a); ALLOCNO_MEMORY_COST (cap) = ALLOCNO_MEMORY_COST (a);
...@@ -1290,8 +1290,6 @@ create_insn_allocnos (rtx x, bool output_p) ...@@ -1290,8 +1290,6 @@ create_insn_allocnos (rtx x, bool output_p)
ALLOCNO_NREFS (a)++; ALLOCNO_NREFS (a)++;
ALLOCNO_FREQ (a) += REG_FREQ_FROM_BB (curr_bb); 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) if (output_p)
bitmap_set_bit (ira_curr_loop_tree_node->modified_regnos, regno); bitmap_set_bit (ira_curr_loop_tree_node->modified_regnos, regno);
} }
...@@ -1709,7 +1707,7 @@ remove_unnecessary_allocnos (void) ...@@ -1709,7 +1707,7 @@ remove_unnecessary_allocnos (void)
prev_a = a; prev_a = a;
ALLOCNO_LOOP_TREE_NODE (a) = parent; ALLOCNO_LOOP_TREE_NODE (a) = parent;
parent->regno_allocno_map[regno] = a; 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 else
{ {
...@@ -2358,20 +2356,18 @@ check_allocno_creation (void) ...@@ -2358,20 +2356,18 @@ check_allocno_creation (void)
FOR_EACH_ALLOCNO (a, ai) 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; continue;
if (ALLOCNO_CAP_MEMBER (a) != NULL) if (ALLOCNO_CAP_MEMBER (a) != NULL)
{ ira_assert (ALLOCNO_CAP (a) != NULL);
ira_assert (ALLOCNO_CAP (a) != NULL);
}
else if (ALLOCNO_CAP (a) == NULL) else if (ALLOCNO_CAP (a) == NULL)
{ ira_assert (loop_tree_node->parent
loop_tree_node = ALLOCNO_LOOP_TREE_NODE (a); ->regno_allocno_map[ALLOCNO_REGNO (a)] != NULL
ira_assert (loop_tree_node->parent && bitmap_bit_p (loop_tree_node->border_allocnos,
->regno_allocno_map[ALLOCNO_REGNO (a)] != NULL ALLOCNO_NUM (a)));
&& bitmap_bit_p (loop_tree_node->border_allocnos,
ALLOCNO_NUM (a)));
}
} }
} }
#endif #endif
......
...@@ -1606,13 +1606,13 @@ print_loop_title (ira_loop_tree_node_t loop_tree_node) ...@@ -1606,13 +1606,13 @@ print_loop_title (ira_loop_tree_node_t loop_tree_node)
ira_assert (loop_tree_node->loop != NULL); ira_assert (loop_tree_node->loop != NULL);
fprintf (ira_dump_file, 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->loop->num,
(loop_tree_node->parent == NULL (loop_tree_node->parent == NULL
? -1 : loop_tree_node->parent->loop->num), ? -1 : loop_tree_node->parent->loop->num),
loop_tree_node->loop->header->index, loop_tree_node->loop->header->index,
loop_depth (loop_tree_node->loop)); 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, " %dr%d", j, ALLOCNO_REGNO (ira_allocnos[j]));
fprintf (ira_dump_file, "\n modified regnos:"); fprintf (ira_dump_file, "\n modified regnos:");
EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->modified_regnos, 0, j, bi) EXECUTE_IF_SET_IN_BITMAP (loop_tree_node->modified_regnos, 0, j, bi)
...@@ -1654,8 +1654,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node) ...@@ -1654,8 +1654,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node)
if (internal_flag_ira_verbose > 1 && ira_dump_file != NULL) if (internal_flag_ira_verbose > 1 && ira_dump_file != NULL)
print_loop_title (loop_tree_node); print_loop_title (loop_tree_node);
bitmap_copy (coloring_allocno_bitmap, loop_tree_node->mentioned_allocnos); bitmap_copy (coloring_allocno_bitmap, loop_tree_node->all_allocnos);
bitmap_ior_into (coloring_allocno_bitmap, loop_tree_node->border_allocnos);
bitmap_copy (consideration_allocno_bitmap, coloring_allocno_bitmap); bitmap_copy (consideration_allocno_bitmap, coloring_allocno_bitmap);
EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, j, bi) EXECUTE_IF_SET_IN_BITMAP (consideration_allocno_bitmap, 0, j, bi)
{ {
...@@ -1669,7 +1668,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node) ...@@ -1669,7 +1668,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node)
/* Process caps. They are processed just once. */ /* Process caps. They are processed just once. */
if (flag_ira_algorithm == IRA_ALGORITHM_MIXED if (flag_ira_algorithm == IRA_ALGORITHM_MIXED
|| flag_ira_algorithm == IRA_ALGORITHM_REGIONAL) || 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]; a = ira_allocnos[j];
if (ALLOCNO_CAP_MEMBER (a) == NULL) if (ALLOCNO_CAP_MEMBER (a) == NULL)
...@@ -1725,12 +1724,11 @@ color_pass (ira_loop_tree_node_t loop_tree_node) ...@@ -1725,12 +1724,11 @@ color_pass (ira_loop_tree_node_t loop_tree_node)
if (subloop_allocno == NULL if (subloop_allocno == NULL
|| ALLOCNO_CAP (subloop_allocno) != NULL) || ALLOCNO_CAP (subloop_allocno) != NULL)
continue; continue;
if ((flag_ira_algorithm == IRA_ALGORITHM_MIXED ira_assert (bitmap_bit_p (subloop_node->all_allocnos,
&& (loop_tree_node->reg_pressure[rclass] ALLOCNO_NUM (subloop_allocno)));
<= ira_available_class_regs[rclass])) if (flag_ira_algorithm == IRA_ALGORITHM_MIXED
|| (hard_regno < 0 && (loop_tree_node->reg_pressure[rclass]
&& ! bitmap_bit_p (subloop_node->mentioned_allocnos, <= ira_available_class_regs[rclass]))
ALLOCNO_NUM (subloop_allocno))))
{ {
if (! ALLOCNO_ASSIGNED_P (subloop_allocno)) if (! ALLOCNO_ASSIGNED_P (subloop_allocno))
{ {
......
...@@ -424,7 +424,7 @@ change_loop (ira_loop_tree_node_t node) ...@@ -424,7 +424,7 @@ change_loop (ira_loop_tree_node_t node)
might get the different hard register. So we need to change might get the different hard register. So we need to change
ALLOCNO_REG. */ ALLOCNO_REG. */
bitmap_and_compl (local_allocno_bitmap, 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); ira_curr_loop_tree_node->border_allocnos);
EXECUTE_IF_SET_IN_REG_SET (local_allocno_bitmap, 0, i, bi) EXECUTE_IF_SET_IN_REG_SET (local_allocno_bitmap, 0, i, bi)
{ {
......
...@@ -111,16 +111,17 @@ struct ira_loop_tree_node ...@@ -111,16 +111,17 @@ struct ira_loop_tree_node
(defined only for the cover classes). */ (defined only for the cover classes). */
int reg_pressure[N_REG_CLASSES]; int reg_pressure[N_REG_CLASSES];
/* Numbers of allocnos referred in the loop node. */ /* Numbers of allocnos referred or living in the loop node (except
bitmap mentioned_allocnos; 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 /* Regnos of pseudos modified in the loop node (including its
subloops). */ subloops). */
bitmap modified_regnos; bitmap modified_regnos;
/* Numbers of allocnos living at the loop borders. */
bitmap border_allocnos;
/* Numbers of copies referred in the corresponding loop. */ /* Numbers of copies referred in the corresponding loop. */
bitmap local_copies; bitmap local_copies;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment