This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Update: reload register allocation patch
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: Update: reload register allocation patch
- From: Bernd Schmidt <bernds at pathia dot cygnus dot co dot uk>
- Date: Sat, 27 Nov 1999 16:09:11 +0000 (GMT)
- cc: Joern Rennecke <amylaar at cygnus dot co dot uk>, gcc-patches at gcc dot gnu dot org
>
> I believe the correct issues first raised with this patch (related to groups
> and non-groups) have been determined to be a non-issue. Do we have any other
> known correctness issues with this patch? Joern?
The following incremental patch fixes the two correctness issues Joern
noticed. allocate_reload_reg is changed never to abort if it runs out of
regs, and inv_reg_alloc_order is used instead of reg_alloc_order (it depends
on the patch I just sent). I didn't address the cost calculation for
multi-reg values yet.
Bernd
diff -dru reload-old/reload1.c ./reload1.c
--- reload-old/reload1.c Sat Nov 27 13:58:15 1999
+++ ./reload1.c Sat Nov 27 14:00:46 1999
@@ -408,8 +408,7 @@
static int reload_reg_free_for_value_p PROTO((int, int, enum reload_type,
rtx, rtx, int, int));
static int reload_reg_reaches_end_p PROTO((int, int, enum reload_type));
-static int allocate_reload_reg PROTO((struct insn_chain *, int, int,
- int));
+static int allocate_reload_reg PROTO((struct insn_chain *, int, int));
static void failed_reload PROTO((rtx, int));
static int set_reload_reg PROTO((int, int));
static void choose_reload_regs_init PROTO((struct insn_chain *, rtx *));
@@ -1628,13 +1627,8 @@
/* Among registers with equal cost, prefer caller-saved ones, or
use REG_ALLOC_ORDER if it is defined. */
|| (this_cost == best_cost
-#ifdef REG_ALLOC_ORDER
- && reg_alloc_order[regno] < reg_alloc_order[best_reg]
-#else
- && call_used_regs[regno]
- && ! call_used_regs[best_reg]
-#endif
- ))
+ && (inv_reg_alloc_order[regno]
+ < inv_reg_alloc_order[best_reg])))
{
best_reg = regno;
best_cost = this_cost;
@@ -4894,15 +4888,14 @@
Set rld[R].reg_rtx to the register allocated.
- If NOERROR is nonzero, we return 1 if successful,
- or 0 if we couldn't find a spill reg and we didn't change anything. */
+ We return 1 if successful, or 0 if we couldn't find a spill reg and
+ we didn't change anything. */
static int
-allocate_reload_reg (chain, r, last_reload, noerror)
+allocate_reload_reg (chain, r, last_reload)
struct insn_chain *chain;
int r;
int last_reload;
- int noerror;
{
rtx insn = chain->insn;
int i, pass, count;
@@ -4939,17 +4932,9 @@
/* I is the index in spill_regs.
We advance it round-robin between insns to use all spill regs
equally, so that inherited reloads have a chance
- of leapfrogging each other. Don't do this, however, when we have
- group needs and failure would be fatal; if we only have a relatively
- small number of spill registers, and more than one of them has
- group needs, then by starting in the middle, we may end up
- allocating the first one in such a way that we are not left with
- sufficient groups to handle the rest. */
+ of leapfrogging each other. */
- if (noerror || ! force_group)
- i = last_spill_reg;
- else
- i = -1;
+ i = last_spill_reg;
for (count = 0; count < n_spills; count++)
{
@@ -5020,21 +5005,13 @@
}
/* We should have found a spill register by now. */
- if (count < n_spills)
- {
- /* I is the index in SPILL_REG_RTX of the reload register we are to
- allocate. Get an rtx for it and find its register number. */
-
- if (set_reload_reg (i, r))
- return 1;
- }
-
- if (noerror)
+ if (count >= n_spills)
return 0;
- failed_reload (insn, r);
+ /* I is the index in SPILL_REG_RTX of the reload register we are to
+ allocate. Get an rtx for it and find its register number. */
- return 1;
+ return set_reload_reg (i, r);
}
/* Initialize all the tables needed to allocate reload registers.
@@ -5201,7 +5178,7 @@
|| rld[reload_order[i]].secondary_p)
&& ! rld[reload_order[i]].optional
&& rld[reload_order[i]].reg_rtx == 0)
- allocate_reload_reg (chain, reload_order[i], 0, inheritance);
+ allocate_reload_reg (chain, reload_order[i], 0);
#endif
/* First see if this pseudo is already available as reloaded
@@ -5558,7 +5535,7 @@
if (i == n_reloads)
continue;
- allocate_reload_reg (chain, r, j == n_reloads - 1, inheritance);
+ allocate_reload_reg (chain, r, j == n_reloads - 1);
#endif
}
@@ -5577,7 +5554,7 @@
if (rld[r].reg_rtx != 0 || rld[r].optional)
continue;
- if (! allocate_reload_reg (chain, r, j == n_reloads - 1, inheritance))
+ if (! allocate_reload_reg (chain, r, j == n_reloads - 1))
break;
}