This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch to fix register allocation bug

Hi Richard,

On 18 Nov 2002, Richard Sandiford wrote:

>   if (best_reg < 0 && !retrying
>       /* Let's not bother with multi-reg allocnos.  */
>       && allocno[num].size == 1)
>     {
> This code "kicked out" another SFmode pseudo and replaced it by our
> DFmode one.  But on this target, DFmode values take two registers.
> The pseudo allocated to the second register wasn't kicked out.
> It's clear that the code was written for pseudos that need only
> one hard register, but checking allocno[num].size isn't enough,
> because it gives the register's size in words.

The .size member is also used to prioritize registers (and for dump
output) and it really should contain the most exact approximation to the
number of hardregs it will need, not the number of words it will take.
That's why I think the appended patch (which is untested!) is better.
Would you be so kind to verify if it fixes your sh bug?

> In this case words are 64 bits wide, but 64-bit values could still
> need more than one register.

Hmm, that's ugly.  Has sh enough registers to make 64bit on this machine
worthy?  Anyway I think this can't be changed now.  Just for curiosity ;-)

Index: global.c
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.86
diff -u -p -r1.86 global.c
--- global.c	4 Nov 2002 16:57:01 -0000	1.86
+++ global.c	18 Nov 2002 13:06:25 -0000
@@ -438,7 +438,11 @@ global_alloc (file)
 	int num = reg_allocno[i];
 	allocno[num].reg = i;
-	allocno[num].size = PSEUDO_REGNO_SIZE (i);
+	if (reg_renumber[i] >= 0)
+	  allocno[num].size = HARD_REGNO_NREGS (reg_renumber[i],
+						PSEUDO_REGNO_MODE (i));
+	else
+	  allocno[num].size = PSEUDO_REGNO_SIZE (i);
 	allocno[num].calls_crossed += REG_N_CALLS_CROSSED (i);
 	allocno[num].n_refs += REG_N_REFS (i);
 	allocno[num].freq += REG_FREQ (i);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]