IRA plans and latest version of IRA patch

Bernd Schmidt bernds_cb1@t-online.de
Wed Jul 2 17:17:00 GMT 2008


On to the next part, better_spill_choice.patch.

> The reload call IRA better_spill_reload_regno_p in reload1.c:find_reg
> to find what pseudo is better to spill for reloads.  Besides old
> heuristic based on spill costs, IRA uses secondary heuristic based on
> length of the pseudo live range where the register pressure is too
> high.  Spilling registers with longer high register pressure live
> range, we improve chance to spill less pseudos for other insns.
> 
> Here is ira.h part concerning better spill register choice:
> 
> extern int better_spill_reload_regno_p (int *, int *, rtx, rtx, rtx);
> 
> Here is ira-color.c part concerning better spill register choice:

At the risk of repeating myself, I'd like to see one of two things (not 
necessarily just for this patch):
  - a stand-alone patch adding this functionality independently of IRA,
    including performance measurements.
  - a compelling argument why this can't be done.

If we could merge individual pieces of IRA, even small ones, the whole 
transition would become so much more manageable in terms of reviewing, 
correctness and performance testing.  I wouldn't like to see IRA go in 
as a big monolithic chunk without making this attempt.

> static int
> calculate_spill_cost (int *regnos, rtx in, rtx out, rtx insn,
>                       int *excess_pressure_live_length,
>                       int *nrefs, int *call_used_count, int *first_hard_regno)
> {
>   int i, cost, regno, hard_regno, j, count, saved_cost, nregs, in_p, out_p;
>   int length;
>   allocno_t a;
> 
>   *nrefs = 0;
>   for (length = count = cost = i = 0;; i++)
>     {
>       regno = regnos[i];
>       if (regno < 0)
>         break;
>       *nrefs += REG_N_REFS (regno);
>       hard_regno = reg_renumber[regno];
>       ira_assert (hard_regno >= 0);
>       a = regno_allocno_map[regno];
>       length += ALLOCNO_EXCESS_PRESSURE_POINTS_NUM (a);
>       cost += ALLOCNO_MEMORY_COST (a) - ALLOCNO_COVER_CLASS_COST (a);
>       nregs = hard_regno_nregs[hard_regno][ALLOCNO_MODE (a)];
>       for (j = 0; j < nregs; j++)
>         if (! TEST_HARD_REG_BIT (call_used_reg_set, hard_regno + j))
>           break;
>       if (j == nregs)
>         count++;
>       in_p = in && REG_P (in) && (int) REGNO (in) == hard_regno;
>       out_p = out && REG_P (out) && (int) REGNO (out) == hard_regno;
>       if ((in_p || out_p)
>           && find_regno_note (insn, REG_DEAD, hard_regno) != NULL_RTX)
>         {
>           saved_cost = 0;
>           if (in_p)
>             saved_cost += memory_move_cost
>                           [ALLOCNO_MODE (a)][ALLOCNO_COVER_CLASS (a)][1];
>           if (out_p)
>             saved_cost
>               += memory_move_cost
>                  [ALLOCNO_MODE (a)][ALLOCNO_COVER_CLASS (a)][0];
>           cost -= REG_FREQ_FROM_BB (BLOCK_FOR_INSN (insn)) * saved_cost;
>         }
>     }
>   *excess_pressure_live_length = length;
>   *call_used_count = count;
>   hard_regno = -1;
>   if (regnos[0] >= 0)
>     {
>       hard_regno = reg_renumber[regnos[0]];
>     }
>   *first_hard_regno = hard_regno;
>   return cost;
> }

At first glance, the only reason this is IRA-dependent is the need for 
data like ALLOCNO_EXCESS_PRESSURE_POINTS or ALLOCNO_MEMORY_COST.

Can a similar (possibly less accurate) function be written for in terms 
of the data available to global.c?  Or, can the additional data be 
computed relatively easily?  If not, why not?


Bernd
-- 
This footer brought to you by insane German lawmakers.
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif



More information about the Gcc-patches mailing list