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 HARD_REGNO_MODE_OK cleanup


Hi
While playing with my code to optimize regclass.c, I found that
HARD_REGNO_MODE_OK on i386 accepts a lot of garbage - VOIDmode, BImode,
some incorrect floating point modes, OImode etc.  This wastes CPU time
in the initialization and makes debugging harder (I've hit reload problem
that should've been caught much sooner if HARD_REGNO_MODE_OK was sane).

This patch fixes it.  Irritantingly enought I didn't find better way
than to enumerate all modes.  This should not be so bad, but I needed
to enumerate the complex modes as well - in non-optimizing compilation
the complex registers can get so far.

Mon Feb 12 18:54:29 CET 2001  Jan Hubicka  <jh@suse.cz>

	* i386.h (VALID_FP_MODE_P, VALID_INT_MODE_P): New.
	(HARD_REGNO_MODE_OK): Refuse all incorrect modes.

Index: egcs/gcc/config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.147
diff -c -3 -p -r1.147 i386.h
*** i386.h	2001/02/08 19:15:37	1.147
--- i386.h	2001/02/12 17:53:18
*************** extern int ix86_arch;
*** 775,780 ****
--- 790,807 ----
      (VALID_SSE_REG_MODE (MODE) && TARGET_SSE ? 1			\
       : VALID_MMX_REG_MODE (MODE) && TARGET_MMX ? 1 : 0)
  
+ #define VALID_FP_MODE_P(mode) \
+     ((mode) == SFmode || (mode) == DFmode || (mode) == TFmode	\
+      || (mode) == XFmode					\
+      || (mode) == SCmode || (mode) == DCmode || (mode) == TCmode\
+      || (mode) == XCmode)
+ 
+ #define VALID_INT_MODE_P(mode) \
+     ((mode) == QImode || (mode) == HImode || (mode) == SImode	\
+      || (mode) == DImode					\
+      || (mode) == CQImode || (mode) == CHImode || (mode) == CSImode \
+      || (mode) == CDImode)
+ 
  /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.  */
  
  #define HARD_REGNO_MODE_OK(REGNO, MODE)				\
*************** extern int ix86_arch;
*** 782,797 ****
    (CC_REGNO_P (REGNO)						\
     ? GET_MODE_CLASS (MODE) == MODE_CC				\
     : GET_MODE_CLASS (MODE) == MODE_CC ? 0			\
!    /* FP regs can only hold floating point; make it clear they	\
!       cannot hold TFmode floats.  */				\
     : FP_REGNO_P (REGNO)						\
!    ? ((GET_MODE_CLASS (MODE) == MODE_FLOAT			\
!        || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)		\
!       && GET_MODE_UNIT_SIZE (MODE) <= 16)\
     : SSE_REGNO_P (REGNO) ? VALID_SSE_REG_MODE (MODE)		\
     : MMX_REGNO_P (REGNO) ? VALID_MMX_REG_MODE (MODE)		\
!    /* Only SSE and MMX regs can hold vector modes.  */		\
!    : VECTOR_MODE_P (MODE) || (MODE) == TImode ? 0		\
     : (REGNO) < 4 ? 1						\
     /* Other regs cannot do byte accesses.  */			\
     : (MODE) != QImode ? 1					\
--- 809,824 ----
    (CC_REGNO_P (REGNO)						\
     ? GET_MODE_CLASS (MODE) == MODE_CC				\
     : GET_MODE_CLASS (MODE) == MODE_CC ? 0			\
!    : GET_MODE_CLASS (MODE) == MODE_RANDOM ? 0			\
!    : GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT ? 0		\
!    /* FP regs can only hold floating point  */			\
     : FP_REGNO_P (REGNO)						\
!    ? VALID_FP_MODE_P (MODE)					\
     : SSE_REGNO_P (REGNO) ? VALID_SSE_REG_MODE (MODE)		\
     : MMX_REGNO_P (REGNO) ? VALID_MMX_REG_MODE (MODE)		\
!    /* We support basic FP operations in integer registers. */   \
!    : !VALID_INT_MODE_P (MODE) && !VALID_FP_MODE_P (MODE)	\
!    ? 0								\
     : (REGNO) < 4 ? 1						\
     /* Other regs cannot do byte accesses.  */			\
     : (MODE) != QImode ? 1					\


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