[PATCH] Honor FLOAT_STORE_FLAG_VALUE in simplify_rtx

Roger Sayle roger@eyesopen.com
Wed Jul 16 16:20:00 GMT 2003



The following patch is another small step towards unification of
GCC's RTL simplification routines.  This change adds support for
FLOAT_STORE_FLAG_VALUE to both simplify_rtx and simplify_replace_rtx.
It also adds the simplification of (lo_sum (high X) X) as X to
simplify_rtx.  These changes should allow simplification of CSE,
combine and the inliner by reusing simplify_rtx without loss of
functionality.

The following patch has been tested on both i686-pc-linux-gnu and
alphaev67-dec-osf5.1 (which defines FLOAT_STORE_FLAG_VALUE) with a
full "make bootstrap", all languages except treelang (on both) and
ada (on Tru64), and then regression tested with a top-level "make
-k check" with no new failures.

Ok for mainline?


2003-07-16  Roger Sayle  <roger@eyesopen.com>

	* simplify-rtx.c (simplify_replace_rtx): Convert constant comparisons
	to MODE_FLOAT constants if FLOAT_STORE_FLAG_VALUE is defined.
	(simplify_rtx): Likewise.  Simplify (lo_sum (high X) X) as X.


Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.147
diff -c -3 -p -r1.147 simplify-rtx.c
*** simplify-rtx.c	6 Jul 2003 12:35:55 -0000	1.147
--- simplify-rtx.c	16 Jul 2003 02:45:18 -0000
*************** simplify_replace_rtx (rtx x, rtx old, rt
*** 269,283 ****
  				     : GET_MODE (XEXP (x, 1)));
  	rtx op0 = simplify_replace_rtx (XEXP (x, 0), old, new);
  	rtx op1 = simplify_replace_rtx (XEXP (x, 1), old, new);
!
! 	return
! 	  simplify_gen_relational (code, mode,
! 				   (op_mode != VOIDmode
! 				    ? op_mode
! 				    : GET_MODE (op0) != VOIDmode
! 				    ? GET_MODE (op0)
! 				    : GET_MODE (op1)),
! 				   op0, op1);
        }

      case '3':
--- 269,292 ----
  				     : GET_MODE (XEXP (x, 1)));
  	rtx op0 = simplify_replace_rtx (XEXP (x, 0), old, new);
  	rtx op1 = simplify_replace_rtx (XEXP (x, 1), old, new);
! 	rtx temp = simplify_gen_relational (code, mode,
! 					    (op_mode != VOIDmode
! 					     ? op_mode
! 					     : GET_MODE (op0) != VOIDmode
! 					       ? GET_MODE (op0)
! 					       : GET_MODE (op1)),
! 					    op0, op1);
! #ifdef FLOAT_STORE_FLAG_VALUE
! 	if (GET_MODE_CLASS (mode) == MODE_FLOAT)
! 	{
! 	  if (temp == const0_rtx)
! 	    temp = CONST0_RTX (mode);
! 	  else if (temp == const_true_rtx)
! 	    temp = CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE (mode),
! 						 mode);
! 	}
! #endif
! 	return temp;
        }

      case '3':
*************** simplify_rtx (rtx x)
*** 3030,3035 ****
--- 3039,3045 ----
  {
    enum rtx_code code = GET_CODE (x);
    enum machine_mode mode = GET_MODE (x);
+   rtx temp;

    switch (GET_RTX_CLASS (code))
      {
*************** simplify_rtx (rtx x)
*** 3058,3069 ****
  					 XEXP (x, 2));

      case '<':
!       return simplify_relational_operation (code,
  					    ((GET_MODE (XEXP (x, 0))
  					      != VOIDmode)
  					     ? GET_MODE (XEXP (x, 0))
  					     : GET_MODE (XEXP (x, 1))),
  					    XEXP (x, 0), XEXP (x, 1));
      case 'x':
        if (code == SUBREG)
  	return simplify_gen_subreg (mode, SUBREG_REG (x),
--- 3068,3091 ----
  					 XEXP (x, 2));

      case '<':
!       temp = simplify_relational_operation (code,
  					    ((GET_MODE (XEXP (x, 0))
  					      != VOIDmode)
  					     ? GET_MODE (XEXP (x, 0))
  					     : GET_MODE (XEXP (x, 1))),
  					    XEXP (x, 0), XEXP (x, 1));
+ #ifdef FLOAT_STORE_FLAG_VALUE
+       if (temp != 0 && GET_MODE_CLASS (mode) == MODE_FLOAT)
+ 	{
+ 	  if (temp == const0_rtx)
+ 	    temp = CONST0_RTX (mode);
+ 	  else
+ 	    temp = CONST_DOUBLE_FROM_REAL_VALUE (FLOAT_STORE_FLAG_VALUE (mode),
+ 						 mode);
+ 	}
+ #endif
+       return temp;
+
      case 'x':
        if (code == SUBREG)
  	return simplify_gen_subreg (mode, SUBREG_REG (x),
*************** simplify_rtx (rtx x)
*** 3074,3081 ****
  	  if (CONSTANT_P (XEXP (x, 0)))
  	    return const1_rtx;
  	}
!       return NULL;
      default:
!       return NULL;
      }
  }
--- 3096,3115 ----
  	  if (CONSTANT_P (XEXP (x, 0)))
  	    return const1_rtx;
  	}
!       break;
!
!     case 'o':
!       if (code == LO_SUM)
! 	{
! 	  /* Convert (lo_sum (high FOO) FOO) to FOO.  */
! 	  if (GET_CODE (XEXP (x, 0)) == HIGH
! 	      && rtx_equal_p (XEXP (XEXP (x, 0), 0), XEXP (x, 1)))
! 	  return XEXP (x, 1);
! 	}
!       break;
!
      default:
!       break;
      }
+   return NULL;
  }


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list