simplify_relational_operation related fix

Jan Hubicka jh@suse.cz
Fri Jul 28 15:04:00 GMT 2000


Hi
The comment before simplify_relational_operation says:

   MODE is the mode of the operands, not that of the result.  If MODE
   is VOIDmode, both operands must also be VOIDmode and we compare the
   operands in "infinite precision".

This does not hold for two calls of this function in simplify_ternary_operation
and combine_siplify_rtx, where simply mode of outer expression is passed.  This
patch changes callers to determine the mode of operands.  This can't be
reliably computed by simplify_relational_operation, since fold_rtx uses it with
two const_int operands but non-VOIDmode mode.

Patch also adds checking code for the VOIDmode to be sane.

Passes bootstrap, testsuite and specint2000 on i386.

Fri Jul 28 20:58:15 CEST 2000  Jan Hubicka  <jh@suse.cz>

	* simplify-rtx.c (simplify_relational_operation): Verify that mode ==
	VOIDmode implies both operands to be VOIDmode.
	(simplify_ternary_operation): Compute properly the mode of comparison.
	* combine.c (combine_simplify_rtx): Likewise.

*** simplify-rtx.c.mode	Fri Jul 28 14:51:20 2000
--- simplify-rtx.c	Fri Jul 28 19:18:27 2000
*************** simplify_relational_operation (code, mod
*** 1691,1696 ****
--- 1690,1700 ----
    int equal, op0lt, op0ltu, op1lt, op1ltu;
    rtx tem;
  
+   if (mode == VOIDmode
+       && (GET_MODE (op0) != VOIDmode
+ 	  || GET_MODE (op1) != VOIDmode))
+     abort();
+ 
    /* If op0 is a compare, extract the comparison arguments from it.  */
    if (GET_CODE (op0) == COMPARE && op1 == const0_rtx)
      op1 = XEXP (op0, 1), op0 = XEXP (op0, 0);
*************** simplify_ternary_operation (code, mode, 
*** 1981,1988 ****
  	return op2;
        else if (GET_RTX_CLASS (GET_CODE (op0)) == '<' && ! side_effects_p (op0))
  	{
  	  rtx temp
! 	     = simplify_relational_operation (GET_CODE (op0), op0_mode,
  					      XEXP (op0, 0), XEXP (op0, 1));
  
  	  /* See if any simplifications were possible.  */
--- 1987,1997 ----
  	return op2;
        else if (GET_RTX_CLASS (GET_CODE (op0)) == '<' && ! side_effects_p (op0))
  	{
+ 	  enum machine_mode cmp_mode = (GET_MODE (XEXP (op0, 0)) == VOIDmode
+ 					? GET_MODE (XEXP (op0, 1))
+ 					: GET_MODE (XEXP (op0, 0)));
  	  rtx temp
! 	     = simplify_relational_operation (GET_CODE (op0), cmp_mode,
  					      XEXP (op0, 0), XEXP (op0, 1));
  
  	  /* See if any simplifications were possible.  */
*** combine.c.mode	Fri Jul 28 14:52:03 2000
--- combine.c	Fri Jul 28 19:35:27 2000
*************** combine_simplify_rtx (x, op0_mode, last,
*** 3639,3646 ****
        temp = simplify_unary_operation (code, mode, XEXP (x, 0), op0_mode);
        break;
      case '<':
!       temp = simplify_relational_operation (code, op0_mode,
! 					    XEXP (x, 0), XEXP (x, 1));
  #ifdef FLOAT_STORE_FLAG_VALUE
        if (temp != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
  	{
--- 3639,3651 ----
        temp = simplify_unary_operation (code, mode, XEXP (x, 0), op0_mode);
        break;
      case '<':
!       {
! 	enum machine_mode cmp_mode = GET_MODE (XEXP (x, 0));
! 	if (cmp_mode == VOIDmode)
! 	  cmp_mode = GET_MODE (XEXP (x, 1));
! 	temp = simplify_relational_operation (code, cmp_mode,
! 					      XEXP (x, 0), XEXP (x, 1));
!       }
  #ifdef FLOAT_STORE_FLAG_VALUE
        if (temp != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
  	{


More information about the Gcc-patches mailing list