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 CLASS_MAX_NREGS fix and REGISTER_MOVE_COST tweek


Hi
The CLASS_MAX_NREGS tends to overestimate the compund SSE/FLOAT classes
and MEMORY_MOVE_COST returns 20 as arbitary high cost, that is lower
than real move cost of PPro.
This patch fixes both resulting in more sane regsiter preferencing.

Sun Apr  8 00:48:59 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* i386.c (ix86_register_move_cost): Fix handling of reformating penalty
	* i386.h (INTEGER_CLASS_P, MAYBE_INTEGER_CLASS_P): New.
	(CLASS_MAX_NREGS): Use it.
Index: i386.c
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.55
diff -c -3 -p -r1.55 i386.c
*** i386.c	2001/04/05 16:20:08	1.55
--- i386.c	2001/04/07 22:45:45
*************** ix86_register_move_cost (mode, class1, c
*** 11633,11645 ****
       stall.  Count this as arbitarily high cost of 20.  */
    if (ix86_secondary_memory_needed (class1, class2, mode, 0))
      {
        if (CLASS_MAX_NREGS (class1, mode) > CLASS_MAX_NREGS (class2, mode))
! 	return 10;
        return (MEMORY_MOVE_COST (mode, class1, 0)
! 	      + MEMORY_MOVE_COST (mode, class2, 1));
      }
!   /* Moves between SSE/MMX and integer unit are expensive.
!      ??? We should make this cost CPU specific.  */
    if (MMX_CLASS_P (class1) != MMX_CLASS_P (class2)
        || SSE_CLASS_P (class1) != SSE_CLASS_P (class2))
      return ix86_cost->mmxsse_to_integer;
--- 11633,11645 ----
       stall.  Count this as arbitarily high cost of 20.  */
    if (ix86_secondary_memory_needed (class1, class2, mode, 0))
      {
+       int add_cost = 0;
        if (CLASS_MAX_NREGS (class1, mode) > CLASS_MAX_NREGS (class2, mode))
! 	  add_cost = 20;
        return (MEMORY_MOVE_COST (mode, class1, 0)
! 	      + MEMORY_MOVE_COST (mode, class2, 1) + add_cost);
      }
!   /* Moves between SSE/MMX and integer unit are expensive.  */
    if (MMX_CLASS_P (class1) != MMX_CLASS_P (class2)
        || SSE_CLASS_P (class1) != SSE_CLASS_P (class2))
      return ix86_cost->mmxsse_to_integer;
Index: i386.h
===================================================================
RCS file: /home/cvs/Repository/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.40
diff -c -3 -p -r1.40 i386.h
*** i386.h	2001/04/04 11:57:08	1.40
--- i386.h	2001/04/07 22:45:46
*************** enum reg_class
*** 1104,1112 ****
--- 1104,1114 ----
  
  #define N_REG_CLASSES (int) LIM_REG_CLASSES
  
+ #define INTEGER_CLASS_P(CLASS) (reg_class_subset_p (CLASS, GENERAL_REGS))
  #define FLOAT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, FLOAT_REGS))
  #define SSE_CLASS_P(CLASS) (reg_class_subset_p (CLASS, SSE_REGS))
  #define MMX_CLASS_P(CLASS) (reg_class_subset_p (CLASS, MMX_REGS))
+ #define MAYBE_INTEGER_CLASS_P(CLASS) (reg_classes_intersect_p (CLASS, GENERAL_REGS))
  #define MAYBE_FLOAT_CLASS_P(CLASS) (reg_classes_intersect_p (CLASS, FLOAT_REGS))
  #define MAYBE_SSE_CLASS_P(CLASS) (reg_classes_intersect_p (SSE_REGS, CLASS))
  #define MAYBE_MMX_CLASS_P(CLASS) (reg_classes_intersect_p (MMX_REGS, CLASS))
*************** enum reg_class
*** 1353,1361 ****
  /* On the 80386, this is the size of MODE in words,
     except in the FP regs, where a single reg is always enough.  */
  #define CLASS_MAX_NREGS(CLASS, MODE)					\
!  (FLOAT_CLASS_P (CLASS) || SSE_CLASS_P (CLASS) || MMX_CLASS_P (CLASS)	\
    ? 1									\
!   : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  
  /* A C expression whose value is nonzero if pseudos that have been
     assigned to registers of class CLASS would likely be spilled
--- 1355,1364 ----
  /* On the 80386, this is the size of MODE in words,
     except in the FP regs, where a single reg is always enough.  */
  #define CLASS_MAX_NREGS(CLASS, MODE)					\
!  (!MAYBE_INTEGER_CLASS_P (CLASS)					\
    ? 1									\
!   : ((GET_MODE_SIZE ((MODE) == TFmode ? XFmode : (MODE))		\
!      + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  
  /* A C expression whose value is nonzero if pseudos that have been
     assigned to registers of class CLASS would likely be spilled


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