Bug fix for reload_combine applied

Joern Rennecke amylaar@cygnus.co.uk
Wed Dec 9 11:43:00 GMT 1998


Wed Dec  9 19:36:57 1998  J"orn Rennecke <amylaar@cygnus.co.uk>

	* reload1.c (reload_combine, reload_combine_note_store):
	Make STORE_RUID always valid.
	(reload_combine): Check if BASE is clobbered too early.

Index: reload1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/reload1.c,v
retrieving revision 1.110
diff -p -r1.110 reload1.c
*** reload1.c	1998/12/08 12:14:30	1.110
--- reload1.c	1998/12/09 19:37:15
*************** struct reg_use { rtx insn, *usep; };
*** 9357,9363 ****
     register (which is first among these we have seen since we scan backwards),
     OFFSET contains the constant offset that is added to the register in
     all encountered uses, and USE_RUID indicates the first encountered, i.e.
!    last, of these uses.  */
  static struct
    {
      struct reg_use reg_use[RELOAD_COMBINE_MAX_USES];
--- 9357,9366 ----
     register (which is first among these we have seen since we scan backwards),
     OFFSET contains the constant offset that is added to the register in
     all encountered uses, and USE_RUID indicates the first encountered, i.e.
!    last, of these uses.
!    STORE_RUID is always meaningful if we only want to use a value in a
!    register in a different place: it denotes the next insn in the insn
!    stream (i.e. the last ecountered) that sets or clobbers the register.  */
  static struct
    {
      struct reg_use reg_use[RELOAD_COMBINE_MAX_USES];
*************** reload_combine ()
*** 9405,9417 ****
    last_label_ruid = reload_combine_ruid = 0;
    for (i = FIRST_PSEUDO_REGISTER - 1; i >= 0; --i)
      {
        if (fixed_regs[i])
  	reg_state[i].use_index = -1;
        else
! 	{
! 	  reg_state[i].use_index = RELOAD_COMBINE_MAX_USES;
! 	  reg_state[i].store_ruid = reload_combine_ruid;
! 	}
      }
  
    for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
--- 9408,9418 ----
    last_label_ruid = reload_combine_ruid = 0;
    for (i = FIRST_PSEUDO_REGISTER - 1; i >= 0; --i)
      {
+       reg_state[i].store_ruid = reload_combine_ruid;
        if (fixed_regs[i])
  	reg_state[i].use_index = -1;
        else
! 	reg_state[i].use_index = RELOAD_COMBINE_MAX_USES;
      }
  
    for (insn = get_last_insn (); insn; insn = PREV_INSN (insn))
*************** reload_combine ()
*** 9493,9502 ****
--- 9494,9507 ----
  		    }
  		}
  	    }
+ 	  /* Check that PREV_SET is indeed (set (REGX) (CONST_INT)) and that
+ 	     (REGY), i.e. BASE, is not clobbered before the last use we'll
+ 	     create.  */
  	  if (prev_set
  	      && GET_CODE (SET_SRC (prev_set)) == CONST_INT
  	      && rtx_equal_p (SET_DEST (prev_set), reg)
  	      && reg_state[regno].use_index >= 0
+ 	      && reg_state[REGNO (base)].store_ruid <= reg_state[regno].use_ruid
  	      && reg_sum)
  	    {
  	      int i;
*************** reload_combine ()
*** 9588,9594 ****
  	{
  	  if (REG_NOTE_KIND (note) == REG_INC
  	      && GET_CODE (XEXP (note, 0)) == REG)
! 	    reg_state[REGNO (XEXP (note, 0))].use_index = -1;
  	}
      }
  }
--- 9593,9604 ----
  	{
  	  if (REG_NOTE_KIND (note) == REG_INC
  	      && GET_CODE (XEXP (note, 0)) == REG)
! 	    {
! 	      int regno = REGNO (XEXP (note, 0));
! 
! 	      reg_state[regno].store_ruid = reload_combine_ruid;
! 	      reg_state[regno].use_index = -1;
! 	    }
  	}
      }
  }
*************** reload_combine_note_store (dst, set)
*** 9616,9622 ****
    /* note_stores might have stripped a STRICT_LOW_PART, so we have to be
       careful with registers / register parts that are not full words.  */
    if (size < (unsigned) UNITS_PER_WORD)
!     reg_state[regno].use_index = -1;
    else
      {
        for (i = size / UNITS_PER_WORD - 1 + regno; i >= regno; i--)
--- 9626,9635 ----
    /* note_stores might have stripped a STRICT_LOW_PART, so we have to be
       careful with registers / register parts that are not full words.  */
    if (size < (unsigned) UNITS_PER_WORD)
!     {
!       reg_state[regno].use_index = -1;
!       reg_state[regno].store_ruid = reload_combine_ruid;
!     }
    else
      {
        for (i = size / UNITS_PER_WORD - 1 + regno; i >= regno; i--)



More information about the Gcc-patches mailing list