Possible CSE quirk involving SUBREG on the i386

Richard Henderson rth@cygnus.com
Wed Jul 1 03:33:00 GMT 1998


On Tue, Jun 30, 1998 at 03:04:46PM -0600, Jeffrey A Law wrote:
>   > It appears that CSE changed (reg/v:HI 23) in insn 16 to
>   > (subreg:HI (reg:SI 22) 0) yet it did not perform this
>   > same substitution in insn 18.  I would have expected
>   > the same substitution in both places.
> In that case, you might see if it was rejected because the perceived
> cost wasn't worth the benefit.  It may also be the case that the
> zero_extendhisi pattern won't accept a subreg.  I haven't looked.

Ho hum.  The explanation is simple here -- MODES_TIEABLE_P.

I believe that we can do slightly better for this; while only
the first four int regs can hold QImode values, all of them 
can hold HImode values.

This happens to cure this exact problem, but the same problem
will occur with unsigned char, and I don't see that we can do
anything about it.


r~


	* i386.h (HARD_REGNO_MODE_OK): Kill spurrious test.
	(MODES_TIEABLE_P): Tie SImode and HImode.

Index: config/i386/i386.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.25
diff -c -p -d -r1.25 i386.h
*** i386.h	1998/06/20 00:04:17	1.25
--- i386.h	1998/07/01 10:28:31
*************** extern int ix86_arch;
*** 639,646 ****
     for cross-compiler testing.  */
  
  #define HARD_REGNO_MODE_OK(REGNO, MODE) \
!   ((REGNO) < 2 ? 1						\
!    : (REGNO) < 4 ? 1						\
     : FP_REGNO_P (REGNO)						\
     ? (((int) GET_MODE_CLASS (MODE) == (int) MODE_FLOAT		\
         || (int) GET_MODE_CLASS (MODE) == (int) MODE_COMPLEX_FLOAT)	\
--- 639,645 ----
     for cross-compiler testing.  */
  
  #define HARD_REGNO_MODE_OK(REGNO, MODE) \
!   ((REGNO) < 4 ? 1						\
     : FP_REGNO_P (REGNO)						\
     ? (((int) GET_MODE_CLASS (MODE) == (int) MODE_FLOAT		\
         || (int) GET_MODE_CLASS (MODE) == (int) MODE_COMPLEX_FLOAT)	\
*************** extern int ix86_arch;
*** 653,659 ****
     If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
     for any hard reg, then this must be 0 for correct output.  */
  
! #define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2))
  
  /* Specify the registers used for certain standard purposes.
     The values of these macros are register numbers.  */
--- 652,661 ----
     If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
     for any hard reg, then this must be 0 for correct output.  */
  
! #define MODES_TIEABLE_P(MODE1, MODE2)				\
!   ((MODE1) == (MODE2)						\
!    || ((MODE1) == SImode && (MODE2) == HImode			\
!        || (MODE1) == HImode && (MODE2) == SImode))
  
  /* Specify the registers used for certain standard purposes.
     The values of these macros are register numbers.  */



More information about the Gcc-patches mailing list