Commit 548a6322 by Vladimir Makarov Committed by Vladimir Makarov

re PR rtl-optimization/37948 (IRA generates slower code)

2008-11-07  Vladimir Makarov  <vmakarov@redhat.com>
	    
	PR rtl-optimizations/37948
	* ira-int.h (struct ira_allocno_copy): New member constraint_p.
	(ira_create_copy, ira_add_allocno_copy): New parameter.

	* ira-conflicts.c (process_regs_for_copy): New parameter.  Pass it
	to ira_add_allocno_copy.
	(process_reg_shuffles, add_insn_allocno_copies): Pass a new
	parameter to process_regs_for_copy.
	(propagate_copies): Pass a new parameter to ira_add_allocno_copy.
	Fix typo in passing second allocno to ira_add_allocno_copy.

	* ira-color.c (update_conflict_hard_regno_costs): Use head of
	coalesced allocnos list.
	(assign_hard_reg): Ditto.  Check that assigned allocnos are not in
	the graph.
	(add_ira_allocno_to_bucket): Rename to add_allocno_to_bucket.
	(add_ira_allocno_to_ordered_bucket): Rename to
	add_allocno_to_ordered_bucket.
	(push_ira_allocno_to_stack): Rename to push_allocno_to_stack.  Use
	head of coalesced allocnos list.
	(push_allocnos_to_stack): Remove calculation of ALLOCNO_TEMP.
	Check that it is aready calculated.
	(push_ira_allocno_to_spill): Rename to push_ira_allocno_to_spill.
	(setup_allocno_left_conflicts_num): Use head of coalesced allocnos
	list.
	(coalesce_allocnos): Do extended coalescing too.

	* ira-emit.c (add_range_and_copies_from_move_list): Pass a new
	parameter to ira_add_allocno_copy.

	* ira-build.c (ira_create_copy, ira_add_allocno_copy): Add a new
	parameter.
	(print_copy): Print copy origination too.

	* ira-costs.c (scan_one_insn): Use alloc_pref for load from
	equivalent memory.

From-SVN: r141753
parent befc2509
2008-11-07 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimizations/37948
* ira-int.h (struct ira_allocno_copy): New member constraint_p.
(ira_create_copy, ira_add_allocno_copy): New parameter.
* ira-conflicts.c (process_regs_for_copy): New parameter. Pass it
to ira_add_allocno_copy.
(process_reg_shuffles, add_insn_allocno_copies): Pass a new
parameter to process_regs_for_copy.
(propagate_copies): Pass a new parameter to ira_add_allocno_copy.
Fix typo in passing second allocno to ira_add_allocno_copy.
* ira-color.c (update_conflict_hard_regno_costs): Use head of
coalesced allocnos list.
(assign_hard_reg): Ditto. Check that assigned allocnos are not in
the graph.
(add_ira_allocno_to_bucket): Rename to add_allocno_to_bucket.
(add_ira_allocno_to_ordered_bucket): Rename to
add_allocno_to_ordered_bucket.
(push_ira_allocno_to_stack): Rename to push_allocno_to_stack. Use
head of coalesced allocnos list.
(push_allocnos_to_stack): Remove calculation of ALLOCNO_TEMP.
Check that it is aready calculated.
(push_ira_allocno_to_spill): Rename to push_ira_allocno_to_spill.
(setup_allocno_left_conflicts_num): Use head of coalesced allocnos
list.
(coalesce_allocnos): Do extended coalescing too.
* ira-emit.c (add_range_and_copies_from_move_list): Pass a new
parameter to ira_add_allocno_copy.
* ira-build.c (ira_create_copy, ira_add_allocno_copy): Add a new
parameter.
(print_copy): Print copy origination too.
* ira-costs.c (scan_one_insn): Use alloc_pref for load from
equivalent memory.
2008-11-10 Kaz Kojima <kkojima@gcc.gnu.org>
PR rtl-optimization/37514
......
......@@ -961,9 +961,10 @@ find_allocno_copy (ira_allocno_t a1, ira_allocno_t a2, rtx insn,
}
/* Create and return copy with given attributes LOOP_TREE_NODE, FIRST,
SECOND, FREQ, and INSN. */
SECOND, FREQ, CONSTRAINT_P, and INSN. */
ira_copy_t
ira_create_copy (ira_allocno_t first, ira_allocno_t second, int freq, rtx insn,
ira_create_copy (ira_allocno_t first, ira_allocno_t second, int freq,
bool constraint_p, rtx insn,
ira_loop_tree_node_t loop_tree_node)
{
ira_copy_t cp;
......@@ -973,6 +974,7 @@ ira_create_copy (ira_allocno_t first, ira_allocno_t second, int freq, rtx insn,
cp->first = first;
cp->second = second;
cp->freq = freq;
cp->constraint_p = constraint_p;
cp->insn = insn;
cp->loop_tree_node = loop_tree_node;
VEC_safe_push (ira_copy_t, heap, copy_vec, cp);
......@@ -1081,7 +1083,8 @@ ira_swap_allocno_copy_ends_if_necessary (ira_copy_t cp)
LOOP_TREE_NODE. */
ira_copy_t
ira_add_allocno_copy (ira_allocno_t first, ira_allocno_t second, int freq,
rtx insn, ira_loop_tree_node_t loop_tree_node)
bool constraint_p, rtx insn,
ira_loop_tree_node_t loop_tree_node)
{
ira_copy_t cp;
......@@ -1090,7 +1093,8 @@ ira_add_allocno_copy (ira_allocno_t first, ira_allocno_t second, int freq,
cp->freq += freq;
return cp;
}
cp = ira_create_copy (first, second, freq, insn, loop_tree_node);
cp = ira_create_copy (first, second, freq, constraint_p, insn,
loop_tree_node);
ira_assert (first != NULL && second != NULL);
ira_add_allocno_copy_to_list (cp);
ira_swap_allocno_copy_ends_if_necessary (cp);
......@@ -1101,9 +1105,11 @@ ira_add_allocno_copy (ira_allocno_t first, ira_allocno_t second, int freq,
static void
print_copy (FILE *f, ira_copy_t cp)
{
fprintf (f, " cp%d:a%d(r%d)<->a%d(r%d)@%d\n", cp->num,
fprintf (f, " cp%d:a%d(r%d)<->a%d(r%d)@%d:%s\n", cp->num,
ALLOCNO_NUM (cp->first), ALLOCNO_REGNO (cp->first),
ALLOCNO_NUM (cp->second), ALLOCNO_REGNO (cp->second), cp->freq);
ALLOCNO_NUM (cp->second), ALLOCNO_REGNO (cp->second), cp->freq,
cp->insn != NULL
? "move" : cp->constraint_p ? "constraint" : "shuffle");
}
/* Print info about copy CP into stderr. */
......
......@@ -329,7 +329,8 @@ go_through_subreg (rtx x, int *offset)
registers. When nothing is changed, the function returns
FALSE. */
static bool
process_regs_for_copy (rtx reg1, rtx reg2, rtx insn, int freq)
process_regs_for_copy (rtx reg1, rtx reg2, bool constraint_p,
rtx insn, int freq)
{
int allocno_preferenced_hard_regno, cost, index, offset1, offset2;
bool only_regs_p;
......@@ -363,7 +364,8 @@ process_regs_for_copy (rtx reg1, rtx reg2, rtx insn, int freq)
{
cp = ira_add_allocno_copy (ira_curr_regno_allocno_map[REGNO (reg1)],
ira_curr_regno_allocno_map[REGNO (reg2)],
freq, insn, ira_curr_loop_tree_node);
freq, constraint_p, insn,
ira_curr_loop_tree_node);
bitmap_set_bit (ira_curr_loop_tree_node->local_copies, cp->num);
return true;
}
......@@ -426,7 +428,7 @@ process_reg_shuffles (rtx reg, int op_num, int freq)
|| recog_data.operand_type[i] != OP_OUT)
continue;
process_regs_for_copy (reg, another_reg, NULL_RTX, freq);
process_regs_for_copy (reg, another_reg, false, NULL_RTX, freq);
}
}
......@@ -451,7 +453,7 @@ add_insn_allocno_copies (rtx insn)
REG_P (SET_SRC (set))
? SET_SRC (set)
: SUBREG_REG (SET_SRC (set))) != NULL_RTX)
process_regs_for_copy (SET_DEST (set), SET_SRC (set), insn, freq);
process_regs_for_copy (SET_DEST (set), SET_SRC (set), false, insn, freq);
else
{
extract_insn (insn);
......@@ -470,7 +472,8 @@ add_insn_allocno_copies (rtx insn)
for (j = 0, commut_p = false; j < 2; j++, commut_p = true)
if ((dup = get_dup (i, commut_p)) != NULL_RTX
&& REG_SUBREG_P (dup)
&& process_regs_for_copy (operand, dup, NULL_RTX, freq))
&& process_regs_for_copy (operand, dup, true,
NULL_RTX, freq))
bound_p = true;
if (bound_p)
continue;
......@@ -524,8 +527,8 @@ propagate_copies (void)
parent_a2 = parent->regno_allocno_map[ALLOCNO_REGNO (a2)];
ira_assert (parent_a1 != NULL && parent_a2 != NULL);
if (! CONFLICT_ALLOCNO_P (parent_a1, parent_a2))
ira_add_allocno_copy (parent_a1, parent_a1, cp->freq,
cp->insn, cp->loop_tree_node);
ira_add_allocno_copy (parent_a1, parent_a2, cp->freq,
cp->constraint_p, cp->insn, cp->loop_tree_node);
}
}
......
......@@ -989,11 +989,14 @@ scan_one_insn (rtx insn)
&& (note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != NULL_RTX
&& MEM_P (XEXP (note, 0)))
{
COSTS_OF_ALLOCNO (allocno_costs,
ALLOCNO_NUM (ira_curr_regno_allocno_map
[REGNO (SET_DEST (set))]))->mem_cost
-= (ira_memory_move_cost[GET_MODE (SET_DEST (set))][GENERAL_REGS][1]
* frequency);
enum reg_class cl = GENERAL_REGS;
rtx reg = SET_DEST (set);
int num = ALLOCNO_NUM (ira_curr_regno_allocno_map[REGNO (reg)]);
if (allocno_pref)
cl = allocno_pref[num];
COSTS_OF_ALLOCNO (allocno_costs, num)->mem_cost
-= ira_memory_move_cost[GET_MODE (reg)][cl][1] * frequency;
record_address_regs (GET_MODE (SET_SRC (set)), XEXP (SET_SRC (set), 0),
0, MEM, SCRATCH, frequency * 2);
}
......
......@@ -863,7 +863,7 @@ add_range_and_copies_from_move_list (move_t list, ira_loop_tree_node_t node,
IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (to), hard_regs_live);
update_costs (from, true, freq);
update_costs (to, false, freq);
cp = ira_add_allocno_copy (from, to, freq, move->insn, NULL);
cp = ira_add_allocno_copy (from, to, freq, false, move->insn, NULL);
if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL)
fprintf (ira_dump_file, " Adding cp%d:a%dr%d-a%dr%d\n",
cp->num, ALLOCNO_NUM (cp->first),
......
......@@ -496,6 +496,7 @@ struct ira_allocno_copy
ira_allocno_t first, second;
/* Execution frequency of the copy. */
int freq;
bool constraint_p;
/* It is a move insn which is an origin of the copy. The member
value for the copy representing two operand insn constraints or
for the copy created to remove register shuffle is NULL. In last
......@@ -859,12 +860,12 @@ extern allocno_live_range_t ira_create_allocno_live_range
extern void ira_finish_allocno_live_range (allocno_live_range_t);
extern void ira_free_allocno_updated_costs (ira_allocno_t);
extern ira_copy_t ira_create_copy (ira_allocno_t, ira_allocno_t,
int, rtx, ira_loop_tree_node_t);
int, bool, rtx, ira_loop_tree_node_t);
extern void ira_add_allocno_copy_to_list (ira_copy_t);
extern void ira_swap_allocno_copy_ends_if_necessary (ira_copy_t);
extern void ira_remove_allocno_copy_from_list (ira_copy_t);
extern ira_copy_t ira_add_allocno_copy (ira_allocno_t, ira_allocno_t, int, rtx,
ira_loop_tree_node_t);
extern ira_copy_t ira_add_allocno_copy (ira_allocno_t, ira_allocno_t, int,
bool, rtx, ira_loop_tree_node_t);
extern int *ira_allocate_cost_vector (enum reg_class);
extern void ira_free_cost_vector (int *, enum reg_class);
......
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