[2/7] Tidy IRA move costs

2012-05-30 Thread Richard Sandiford
The only part of IRA that uses move_costs directly is copy_cost.
It looks like this might be an oversight, since all related costs
already use ira_register_move_cost.

As mentioned in the covering message, the two arrays are usually
the same anyway.  The only hitch is that we have:

  if (!move_cost[mode])
init_move_cost (mode);

so if the move costs for this mode really haven't been calculated yet,
we could potentially end up with different costs then if we used the
normal ira_init_register_move_cost_if_necessary route.  In the former
case we'd use the original move_cost (before the IRA modifications),
while in the latter we'd use the value assigned by
ira_init_register_move_cost via the ira_register_move_cost alias.

Richard


gcc/
* ira-costs.c (copy_cost): Use ira_init_register_move_cost_if_necessary
and ira_register_move_cost instead of init_move_cost and move_cost.

Index: gcc/ira-costs.c
===
--- gcc/ira-costs.c 2012-05-30 18:57:09.040912969 +0100
+++ gcc/ira-costs.c 2012-05-30 19:16:22.921879419 +0100
@@ -359,9 +359,8 @@ copy_cost (rtx x, enum machine_mode mode
 
   if (secondary_class != NO_REGS)
 {
-  if (!move_cost[mode])
-init_move_cost (mode);
-  return (move_cost[mode][(int) secondary_class][(int) rclass]
+  ira_init_register_move_cost_if_necessary (mode);
+  return (ira_register_move_cost[mode][(int) secondary_class][(int) rclass]
  + sri.extra_cost
  + copy_cost (x, mode, secondary_class, to_p, sri));
 }
@@ -374,10 +373,11 @@ copy_cost (rtx x, enum machine_mode mode
   + ira_memory_move_cost[mode][(int) rclass][to_p != 0];
   else if (REG_P (x))
 {
-  if (!move_cost[mode])
-init_move_cost (mode);
+  reg_class_t x_class = REGNO_REG_CLASS (REGNO (x));
+
+  ira_init_register_move_cost_if_necessary (mode);
   return (sri.extra_cost
- + move_cost[mode][REGNO_REG_CLASS (REGNO (x))][(int) rclass]);
+ + ira_register_move_cost[mode][(int) x_class][(int) rclass]);
 }
   else
 /* If this is a constant, we may eventually want to call rtx_cost


Re: [2/7] Tidy IRA move costs

2012-05-30 Thread Vladimir Makarov

On 05/30/2012 02:21 PM, Richard Sandiford wrote:

The only part of IRA that uses move_costs directly is copy_cost.
It looks like this might be an oversight, since all related costs
already use ira_register_move_cost.

move_cost was from code which was part or regclass before.

As mentioned in the covering message, the two arrays are usually
the same anyway.  The only hitch is that we have:

   if (!move_cost[mode])
 init_move_cost (mode);

so if the move costs for this mode really haven't been calculated yet,
we could potentially end up with different costs then if we used the
normal ira_init_register_move_cost_if_necessary route.  In the former
case we'd use the original move_cost (before the IRA modifications),
while in the latter we'd use the value assigned by
ira_init_register_move_cost via the ira_register_move_cost alias.


Ok.