mips64 bugfix

Jeffrey A Law law@cygnus.com
Wed Jan 13 00:13:00 GMT 1999


For a standard 32bit load when TARGET_MIPS64 is enabled, the mips port
will emit a "lw" instruction.

"lw" _sign_ extends the result from 32 to 64 bits.

LOAD_EXTEND_OP unconditionally returns ZERO_EXTEND for the mips port.

Thus, in certain circumstances the compiler would eliminate a zero extension
of a value because it believed upper 32 bits of the value must have been zero
to begin with.

Obviously this loses if the 32bit value had its sign bit on when it was
loaded from memory.

I've checked in this patch to fix the problem:


	* mips.h (LOAD_EXTEND_OP): Correct for SImode and CCmode moves when
	generating code for TARGET_64BIT.

Index: mips.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/mips/mips.h,v
retrieving revision 1.162
diff -c -3 -p -r1.162 mips.h
*** mips.h	1998/12/15 14:10:48	1.162
--- mips.h	1999/01/13 08:00:12
*************** extern int mips_max_skip_funcs;
*** 1603,1610 ****
  /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
     will either zero-extend or sign-extend.  The value of this macro should
     be the code that says which one of the two operations is implicitly
!    done, NIL if none.  */
! #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
  
  /* Define this macro if it is advisable to hold scalars in registers
     in a wider mode than that declared by the program.  In such cases, 
--- 1603,1615 ----
  /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
     will either zero-extend or sign-extend.  The value of this macro should
     be the code that says which one of the two operations is implicitly
!    done, NIL if none. 
! 
!    When in 64 bit mode, mips_move_1word will sign extend SImode and CCmode
!    moves.  All other referces are zero extended.  */
! #define LOAD_EXTEND_OP(MODE) \
!   (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode) \
!    ? SIGN_EXTEND : ZERO_EXTEND)
  
  /* Define this macro if it is advisable to hold scalars in registers
     in a wider mode than that declared by the program.  In such cases, 



More information about the Gcc-patches mailing list