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]

fix execute/950605-1.c


The problem here (at least on Alpha) is that parameter 
promotion rules say that the argument should be passed
as a 64-bit entity, but the "unsigned char" parameter
type says it should be truncated once it gets there.

I'm guessing that the reason store_expr is trying to 
strip the SUBREG here is that it produces code that is
easier to optimize.  However, in the process we were
losing the truncate implied by that SUBREG.

Tested on alphaev6 and i686 linux.


r~


        * expr.c (store_expr): When converting a CONST_INT for storage
        in a SUBREG, convert it to both SUBREG modes before stripping
        the SUBREG.

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.354
diff -c -p -d -r1.354 expr.c
*** expr.c	2001/10/01 23:22:24	1.354
--- expr.c	2001/10/08 16:52:15
*************** store_expr (exp, target, want_value)
*** 4152,4160 ****
        /* If TEMP is a VOIDmode constant, use convert_modes to make
  	 sure that we properly convert it.  */
        if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
! 	temp = convert_modes (GET_MODE (SUBREG_REG (target)),
! 			      TYPE_MODE (TREE_TYPE (exp)), temp,
! 			      SUBREG_PROMOTED_UNSIGNED_P (target));
  
        convert_move (SUBREG_REG (target), temp,
  		    SUBREG_PROMOTED_UNSIGNED_P (target));
--- 4152,4164 ----
        /* If TEMP is a VOIDmode constant, use convert_modes to make
  	 sure that we properly convert it.  */
        if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode)
! 	{
! 	  temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)),
! 				temp, SUBREG_PROMOTED_UNSIGNED_P (target));
! 	  temp = convert_modes (GET_MODE (SUBREG_REG (target)),
! 			        GET_MODE (target), temp,
! 			        SUBREG_PROMOTED_UNSIGNED_P (target));
! 	}
  
        convert_move (SUBREG_REG (target), temp,
  		    SUBREG_PROMOTED_UNSIGNED_P (target));


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