reload_combine bug fix

Joern Rennecke amylaar@cygnus.co.uk
Wed Mar 1 13:12:00 GMT 2000


Since validate_change will blithely accept to change

(insn 15 13 16 (use (reg/i:SI 0 r0)) -1 (insn_list 13 (nil))
    (nil))

(insn 16 15 17 (use (reg/i:SI 0 r0)) -1 (insn_list 15 (nil))
    (nil))

into

(insn 15 13 16 (use (plus:SI (reg:SI 0 r0)
            (reg:SI 4 r4))) -1 (insn_list 13 (nil))
    (nil))

(insn 16 15 17 (use (plus:SI (reg:SI 0 r0)
            (reg:SI 4 r4))) -1 (insn_list 15 (nil))

, the logic to change uses of registers in reload_combine doesn't work right.  

I have added a case in reload_combine_note_use to handle return register USEs
specially.  While I was at that, I also notied that the vanilla REG case
didn't handle multi-hard-register hard regs properly.

Fri Feb 25 02:00:23 2000  J"orn Rennecke <amylaar@cygnus.co.uk>

	* reload1.c (reload_combine_note_use): Handle return register USEs.
	REG case: Handle multi-hard-register hard regs.

Index: reload1.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/reload1.c,v
retrieving revision 1.218.4.6
diff -p -r1.218.4.6 reload1.c
*** reload1.c	1999/07/27 09:06:43	1.218.4.6
--- reload1.c	2000/02/25 02:00:42
*************** reload_combine_note_use (xp, insn)
*** 9825,9830 ****
--- 9825,9845 ----
  	}
        break;
  
+     case USE:
+       /* If this is the USE of a return value, we can't change it.  */
+       if (GET_CODE (XEXP (x, 0)) == REG && REG_FUNCTION_VALUE_P (XEXP (x, 0)))
+ 	{
+ 	/* Mark the return register as used in an unknown fashion.  */
+ 	  rtx reg = XEXP (x, 0);
+ 	  int regno = REGNO (reg);
+ 	  int nregs = HARD_REGNO_NREGS (regno, GET_MODE (reg));
+ 
+ 	  while (--nregs >= 0)
+ 	    reg_state[regno + nregs].use_index = -1;
+ 	  return;
+ 	}
+       break;
+ 
      case CLOBBER:
        if (GET_CODE (SET_DEST (x)) == REG)
  	return;
*************** reload_combine_note_use (xp, insn)
*** 9841,9851 ****
--- 9856,9877 ----
        {
  	int regno = REGNO (x);
  	int use_index;
+ 	int nregs;
  
  	/* Some spurious USEs of pseudo registers might remain.
  	   Just ignore them.  */
  	if (regno >= FIRST_PSEUDO_REGISTER)
  	  return;
+ 
+ 	nregs = HARD_REGNO_NREGS (regno, GET_MODE (x));
+ 
+ 	/* We can't substitute into multi-hard-reg uses.  */
+ 	if (nregs > 1)
+ 	  {
+ 	    while (--nregs >= 0)
+ 	      reg_state[regno + nregs].use_index = -1;
+ 	    return;
+ 	  }
  
  	/* If this register is already used in some unknown fashion, we
  	   can't do anything.


More information about the Gcc-patches mailing list