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]

i386 constant costs tweek



Hi,
the CONST_COSTS in i386.h returns possitive values for various constants.
This makes cse to replace constants by register if register happends
to have the value.  This hurts on i386 mostly, as in resulting insn
chain we need one extra insn to load constant, extra dependancy
and extra registers (register allocator is not always able to hanle
this case properly using REG_EQUIV notes).

It seems to make sense for me to define the costs negaitve, so cse and otherws
will attempt to use constants whenever possible.  I've measured minor code size
decrease in my tests, so this change seems to be a (slight) win.

Honza

Mon Jun  4 19:06:39 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* i386.h (CONST_COSTS): Set constant costs to negative value
	to make CSE preffer them over registers.

Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.185
diff -c -3 -p -r1.185 i386.h
*** i386.h	2001/05/26 00:46:02	1.185
--- i386.h	2001/06/04 17:05:45
*************** while (0)
*** 2369,2385 ****
  
  #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
    case CONST_INT:						\
!     return (unsigned) INTVAL (RTX) < 256 ? 0 : 1;		\
    case CONST:							\
    case LABEL_REF:						\
    case SYMBOL_REF:						\
!     return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 1;		\
  								\
    case CONST_DOUBLE:						\
      {								\
        int code;							\
        if (GET_MODE (RTX) == VOIDmode)				\
! 	return 2;						\
  								\
        code = standard_80387_constant_p (RTX);			\
        return code == 1 ? 0 :					\
--- 2369,2385 ----
  
  #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
    case CONST_INT:						\
!     return (unsigned) INTVAL (RTX) < 256 ? -2 : -1;		\
    case CONST:							\
    case LABEL_REF:						\
    case SYMBOL_REF:						\
!     return flag_pic && SYMBOLIC_CONST (RTX) ? 0 : -1;		\
  								\
    case CONST_DOUBLE:						\
      {								\
        int code;							\
        if (GET_MODE (RTX) == VOIDmode)				\
! 	return -1;						\
  								\
        code = standard_80387_constant_p (RTX);			\
        return code == 1 ? 0 :					\


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