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]

actually sign-extending CONST_INTs in expand_binop


Tue Apr 24 05:26:46 2001  J"orn Rennecke <amylaar@redhat.com>

	* optabs.c (expand_binop): Actually sign-extend CONST_INTs.

Index: optabs.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/optabs.c,v
retrieving revision 1.141
diff -p -r1.141 optabs.c
*** optabs.c	2001/04/19 23:16:46	1.141
--- optabs.c	2001/04/24 04:26:42
*************** expand_binop (mode, binoptab, op0, op1, 
*** 727,739 ****
        /* In case the insn wants input operands in modes different from
  	 the result, convert the operands.  It would seem that we
  	 don't need to convert CONST_INTs, but we do, so that they're
! 	 a properly sign-extended for their modes.  */
  
        if (GET_MODE (op0) != mode0
  	  && mode0 != VOIDmode)
  	xop0 = convert_modes (mode0,
  			      GET_MODE (op0) != VOIDmode
  			      ? GET_MODE (op0)
  			      : mode0,
  			      xop0, unsignedp);
  
--- 727,747 ----
        /* In case the insn wants input operands in modes different from
  	 the result, convert the operands.  It would seem that we
  	 don't need to convert CONST_INTs, but we do, so that they're
! 	 a properly sign-extended for their modes.  Note that convert_modes
! 	 is a no-op if we use MODE0 / MODE1 for the previous mode.
! 	 When we have an extending integer operation, e.g. umulhisi,
! 	 we have to pass MODE (which is wider) as the previous mode.
! 	 However, we must not do this if MODE is not a MODE_INT mode,
! 	 since then the operation becomes nonsentical - fall back to the
! 	 MODE0 / MODE1 no-op then.  */
  
        if (GET_MODE (op0) != mode0
  	  && mode0 != VOIDmode)
  	xop0 = convert_modes (mode0,
  			      GET_MODE (op0) != VOIDmode
  			      ? GET_MODE (op0)
+ 			      : GET_MODE_CLASS (mode) == MODE_INT
+ 			      ? mode
  			      : mode0,
  			      xop0, unsignedp);
  
*************** expand_binop (mode, binoptab, op0, op1, 
*** 742,747 ****
--- 750,757 ----
  	xop1 = convert_modes (mode1,
  			      GET_MODE (op1) != VOIDmode
  			      ? GET_MODE (op1)
+ 			      : GET_MODE_CLASS (mode) == MODE_INT
+ 			      ? mode
  			      : mode1,
  			      xop1, unsignedp);
  


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