diff mbox

Fix caller-save.c:add_used_regs_1 handling of pseudos

Message ID 87lhx1fs50.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford Feb. 23, 2014, 9:14 p.m. UTC
I noticed in passing that this 4.7 cleanup:

  http://article.gmane.org/gmane.comp.gcc.patches/224853

changed caller-save.c:add_used_regs_1 from:

  if (REG_P (x))
    {
      regno = REGNO (x);
      if (!HARD_REGISTER_NUM_P (regno))
        regno = reg_renumber[regno];
      if (regno >= 0)
        for (i = hard_regno_nregs[regno][GET_MODE (x)] - 1; i >= 0; i--)
          SET_REGNO_REG_SET (live, regno + i);
    }
  return 0;

to:

  if (REG_P (x))
    {
      regno = REGNO (x);
      if (HARD_REGISTER_NUM_P (regno))
        bitmap_set_range (live, regno, hard_regno_nregs[regno][GET_MODE (x)]);
      else
        regno = reg_renumber[regno];
    }
  return 0;

so that nothing happens for pseudos.  I've no idea whether this makes
a difference in practice or not but it seems safer to restore the old
behaviour.

Tested on mipsisa64-sde-elf rather than x86_64-linux-gnu since it only
affects reload targets.  OK to install?

Thanks,
Richard


gcc/
	* caller-save.c (add_used_regs_1): Fix handling of pseudos.

Comments

Steven Bosscher Feb. 23, 2014, 11:17 p.m. UTC | #1
On Sun, Feb 23, 2014 at 10:14 PM, Richard Sandiford wrote:
> I noticed in passing that this 4.7 cleanup:
>
>   http://article.gmane.org/gmane.comp.gcc.patches/224853
...
> so that nothing happens for pseudos.  I've no idea whether this makes
> a difference in practice or not but it seems safer to restore the old
> behaviour.
>
> Tested on mipsisa64-sde-elf rather than x86_64-linux-gnu since it only
> affects reload targets.  OK to install?

If it's worked since GCC 4.7, why restore that code?

I prefer an assert that the reg is not a pseudo. If something would
break, it's still possible to restore the old behavior and have an
explanation for why it should be like that.

Ciao!
Steven
Richard Sandiford Feb. 24, 2014, 8 a.m. UTC | #2
Steven Bosscher <stevenb.gcc@gmail.com> writes:
> On Sun, Feb 23, 2014 at 10:14 PM, Richard Sandiford wrote:
>> I noticed in passing that this 4.7 cleanup:
>>
>>   http://article.gmane.org/gmane.comp.gcc.patches/224853
> ...
>> so that nothing happens for pseudos.  I've no idea whether this makes
>> a difference in practice or not but it seems safer to restore the old
>> behaviour.
>>
>> Tested on mipsisa64-sde-elf rather than x86_64-linux-gnu since it only
>> affects reload targets.  OK to install?
>
> If it's worked since GCC 4.7, why restore that code?

OK, fair enough.  I'll withdraw the patch.

Thanks,
Richard
diff mbox

Patch

Index: gcc/caller-save.c
===================================================================
--- gcc/caller-save.c	2014-01-02 22:16:03.383281697 +0000
+++ gcc/caller-save.c	2014-02-23 11:04:27.519785327 +0000
@@ -1339,7 +1339,7 @@  insert_save (struct insn_chain *chain, i
 static int
 add_used_regs_1 (rtx *loc, void *data)
 {
-  unsigned int regno;
+  int regno;
   regset live;
   rtx x;
 
@@ -1348,10 +1348,10 @@  add_used_regs_1 (rtx *loc, void *data)
   if (REG_P (x))
     {
       regno = REGNO (x);
-      if (HARD_REGISTER_NUM_P (regno))
-	bitmap_set_range (live, regno, hard_regno_nregs[regno][GET_MODE (x)]);
-      else
+      if (!HARD_REGISTER_NUM_P (regno))
 	regno = reg_renumber[regno];
+      if (regno >= 0)
+	bitmap_set_range (live, regno, hard_regno_nregs[regno][GET_MODE (x)]);
     }
   return 0;
 }