This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Re: middle-end/1719: Abort in local-alloc.c


Jeffrey A Law writes:
 > REG_N_REFS is supposed to scaled based on the loop depth of the reference;
 > something like this:
 > 
 >            REG_N_REFS (i) += (optimize_size ? 1  : pbi->bb->loop_depth + 1);
 > 
 > So you need to get at the loop depth of the insn in question.  Hopefully
 > that information is available at the time you need it.
 > 
 > I'd also have the code to update REG_N_REFS immediately follow the code to
 > update REG_N_SETS.

Sorry about the delay. I had my day job to attend to! Anyway, here is a new
patch which is hopefully correct.

Ian

ChangeLog entry:

Sun Feb  4 07:06:30 2001  Ian Dall  <ian@gateway.beware.dropbear.id.au>

	* regclass.c (scan_one_insn, regclass): Add loop_depth
 	argument. Increment register reference count by loop_depth when
 	inserting new insn.

Patch:

*** ../../gcc/gcc/regclass.c	Sat Jan 27 05:21:04 2001
--- regclass.c	Sun Feb  4 07:18:54 2001
***************
*** 757,763 ****
  
  static int loop_cost;
  
! static rtx scan_one_insn	PARAMS ((rtx, int));
  static void record_operand_costs PARAMS ((rtx, struct costs *, struct reg_pref *));
  static void dump_regclass	PARAMS ((FILE *));
  static void record_reg_classes	PARAMS ((int, int, rtx *, enum machine_mode *,
--- 757,763 ----
  
  static int loop_cost;
  
! static rtx scan_one_insn	PARAMS ((rtx, int, int));
  static void record_operand_costs PARAMS ((rtx, struct costs *, struct reg_pref *));
  static void dump_regclass	PARAMS ((FILE *));
  static void record_reg_classes	PARAMS ((int, int, rtx *, enum machine_mode *,
***************
*** 918,926 ****
     there.  */
  
  static rtx
! scan_one_insn (insn, pass)
       rtx insn;
       int pass;
  {
    enum rtx_code code = GET_CODE (insn);
    enum rtx_code pat_code;
--- 918,927 ----
     there.  */
  
  static rtx
! scan_one_insn (insn, pass, loop_depth)
       rtx insn;
       int pass;
+      int loop_depth;
  {
    enum rtx_code code = GET_CODE (insn);
    enum rtx_code pat_code;
***************
*** 1004,1013 ****
  	      BLOCK_HEAD (b) = newinsn;
  	}
  
!       /* This makes one more setting of new insns's dest.  */
        REG_N_SETS (REGNO (recog_data.operand[0]))++;
  
-       *recog_data.operand_loc[1] = recog_data.operand[0];
        for (i = recog_data.n_dups - 1; i >= 0; i--)
  	if (recog_data.dup_num[i] == 1)
  	  *recog_data.dup_loc[i] = recog_data.operand[0];
--- 1005,1017 ----
  	      BLOCK_HEAD (b) = newinsn;
  	}
  
!       *recog_data.operand_loc[1] = recog_data.operand[0];
! 
!       /* This makes one more setting of new insns's dest and one more
!          reference to register.  */
        REG_N_SETS (REGNO (recog_data.operand[0]))++;
+       REG_N_REFS (REGNO (recog_data.operand[0])) += loop_depth + 1;
  
        for (i = recog_data.n_dups - 1; i >= 0; i--)
  	if (recog_data.dup_num[i] == 1)
  	  *recog_data.dup_loc[i] = recog_data.operand[0];
***************
*** 1137,1143 ****
  	{
  	  loop_cost = 1;
  	  for (insn = f; insn; insn = NEXT_INSN (insn))
! 	    insn = scan_one_insn (insn, pass);
  	}
        else
  	for (index = 0; index < n_basic_blocks; index++)	
--- 1141,1147 ----
  	{
  	  loop_cost = 1;
  	  for (insn = f; insn; insn = NEXT_INSN (insn))
! 	    insn = scan_one_insn (insn, pass, 0);
  	}
        else
  	for (index = 0; index < n_basic_blocks; index++)	
***************
*** 1154,1160 ****
  	      loop_cost = 1 << (2 * MIN (bb->loop_depth, 5));
  	    for (insn = bb->head; ; insn = NEXT_INSN (insn))
  	      {
! 		insn = scan_one_insn (insn, pass);
  		if (insn == bb->end)
  		  break;
  	      }
--- 1158,1164 ----
  	      loop_cost = 1 << (2 * MIN (bb->loop_depth, 5));
  	    for (insn = bb->head; ; insn = NEXT_INSN (insn))
  	      {
! 		insn = scan_one_insn (insn, pass, bb->loop_depth);
  		if (insn == bb->end)
  		  break;
  	      }

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