This is the mail archive of the gcc-patches@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]

regclass tweak 1


Hi
The code I've enabled by my previous patch seems to have some pifalls.
First it ignores memory references to constant pool, because their REG_EQUIV
note is not MEM but constant and it decreases cost for full moving cost.
This is not quite correct, because if next insn requires operand in register
we have to make moving anyway.
I've changed this to decrease by cost minus one, this is consistent
with way we preferre insns that allows memory operands.

Now following code:

int a;
main()
{
  asm(""::"r"(a));
}

Produces preferrences:

;; Register 24 costs: NO_REGS:0 AREG:0 DREG:0 CREG:0 BREG:0 SIREG:0 DIREG:0 AD_REGS:0 Q_REGS:0 NON_Q_REGS:0 INDEX_REGS:0 GENERAL_REGS:0 FP_TOP_REG:8 FP_SECOND_REG:8 FLOAT_REGS:8 FLOAT_INT_REGS:8 ALL_REGS:8 MEM:1

This seems to be OK. After my previous patch it had cost 0, before it cost 4
(incorrect).

If insn were allowing memory too, there memory cost would be 0 and regclass will not
choose any preference, so it will end up in register.

Honza

Mon Nov 22 16:40:28 MET 1999  Jan Hubicka  <hubcika@freesoft.cz>
	* regclass.c (scan_one_insn): Handle loads from constant pool as loads
	from stack, decrease cost only by move cost minus one.
	
*** regclass.c	1999/11/22 13:43:39	1.72
--- regclass.c	1999/11/22 15:30:19
*************** scan_one_insn (insn, pass)
*** 838,857 ****
      }
    memset (subreg_changes_size, 0, sizeof (subreg_changes_size));
  
!   /* If this insn loads a parameter from its stack slot, then
!      it represents a savings, rather than a cost, if the
!      parameter is stored in memory.  Record this fact.  */
  
    if (set != 0 && GET_CODE (SET_DEST (set)) == REG
        && GET_CODE (SET_SRC (set)) == MEM
        && (note = find_reg_note (insn, REG_EQUIV,
  				NULL_RTX)) != 0
!       && GET_CODE (XEXP (note, 0)) == MEM)
      {
        costs[REGNO (SET_DEST (set))].mem_cost
  	-= (MEMORY_MOVE_COST (GET_MODE (SET_DEST (set)),
  			      GENERAL_REGS, 1)
! 	    * loop_cost);
        record_address_regs (XEXP (SET_SRC (set), 0),
  			   BASE_REG_CLASS, loop_cost * 2);
        return insn;
--- 1465,1489 ----
      }
    memset (subreg_changes_size, 0, sizeof (subreg_changes_size));
  
!   /* If this insn loads a parameter from its stack slot
!      or contant pool, then it represents a savings, rather than
!      a cost, if the parameter is stored in memory.  Record this
!      fact.  */
  
    if (set != 0 && GET_CODE (SET_DEST (set)) == REG
        && GET_CODE (SET_SRC (set)) == MEM
        && (note = find_reg_note (insn, REG_EQUIV,
  				NULL_RTX)) != 0
!       && (GET_CODE (XEXP (note, 0)) == MEM
! 	  || CONSTANT_P (XEXP (note, 0))))
      {
+       /* Decrement only by cost - 1 because in case this insn will be
+ 	 followed in single insn requiring register, we would get cost
+ 	 0 otherwise.  */
        costs[REGNO (SET_DEST (set))].mem_cost
  	-= (MEMORY_MOVE_COST (GET_MODE (SET_DEST (set)),
  			      GENERAL_REGS, 1)
! 	    * loop_cost) - 1;
        record_address_regs (XEXP (SET_SRC (set), 0),
  			   BASE_REG_CLASS, loop_cost * 2);
        return insn;


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