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]
Other format: [Raw text]

Re: [PATCH] fix PR opt/2391 (mostly ARM)


Richard Henderson writes:
 > MODE_INT is the wrong enum.  If you want "nothing", use VOIDmode.

Thanks, fixed that.  Also another minor improvement in the cached_*
functions I check knonw_x first and then knonw_mode.

Here is what I checked in.

Adam

2003-02-13  Adam Nemet  <anemet@lnxw.com>
        PR opt/2391 
        * combine.c: Fix spelling in comment.
        (cached_nonzero_bits): New function.
        (cached_num_sign_bit_copies): New function.
	(nonzero_bits_with_known): New macro.
	(num_sign_bit_copies_with_known): New macro.
        (nonzero_bits1): Rename from nonzero_bits.  Add three new
	arguments.  Change calls from nonzero_bits to
	nonzero_bits_with_known.
        (num_sign_bit_copies1): Rename from num_sign_bit_copies.  Add
	three new arguments.  Change calls from num_sign_bit_copies to
	num_sign_bit_copies_with_known.
        (nonzero_bits): New macro.
        (num_sign_bit_copies): New macro.
        (update_table_tick): Don't traverse identical subexpression more
	than once.
        (get_last_value_validate): Likewise.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.339
diff -c -r1.339 combine.c
*** combine.c	11 Feb 2003 18:05:55 -0000	1.339
--- combine.c	14 Feb 2003 05:28:03 -0000
***************
*** 139,144 ****
--- 139,150 ----
  #define UWIDE_SHIFT_LEFT_BY_BITS_PER_WORD(val) \
    (((unsigned HOST_WIDE_INT) (val) << (BITS_PER_WORD - 1)) << 1)
  
+ #define nonzero_bits(X, M) \
+   cached_nonzero_bits (X, M, NULL_RTX, VOIDmode, 0)
+ 
+ #define num_sign_bit_copies(X, M) \
+   cached_num_sign_bit_copies (X, M, NULL_RTX, VOIDmode, 0)
+ 
  /* Maximum register number, which is the size of the tables below.  */
  
  static unsigned int combine_max_regno;
***************
*** 198,204 ****
  static sbitmap refresh_blocks;
  
  /* The next group of arrays allows the recording of the last value assigned
!    to (hard or pseudo) register n.  We use this information to see if a
     operation being processed is redundant given a prior operation performed
     on the register.  For example, an `and' with a constant is redundant if
     all the zero bits are already known to be turned off.
--- 204,210 ----
  static sbitmap refresh_blocks;
  
  /* The next group of arrays allows the recording of the last value assigned
!    to (hard or pseudo) register n.  We use this information to see if an
     operation being processed is redundant given a prior operation performed
     on the register.  For example, an `and' with a constant is redundant if
     all the zero bits are already known to be turned off.
***************
*** 371,378 ****
  static rtx apply_distributive_law  PARAMS ((rtx));
  static rtx simplify_and_const_int  PARAMS ((rtx, enum machine_mode, rtx,
  					    unsigned HOST_WIDE_INT));
! static unsigned HOST_WIDE_INT nonzero_bits  PARAMS ((rtx, enum machine_mode));
! static unsigned int num_sign_bit_copies  PARAMS ((rtx, enum machine_mode));
  static int merge_outer_ops	PARAMS ((enum rtx_code *, HOST_WIDE_INT *,
  					 enum rtx_code, HOST_WIDE_INT,
  					 enum machine_mode, int *));
--- 377,396 ----
  static rtx apply_distributive_law  PARAMS ((rtx));
  static rtx simplify_and_const_int  PARAMS ((rtx, enum machine_mode, rtx,
  					    unsigned HOST_WIDE_INT));
! static unsigned HOST_WIDE_INT cached_nonzero_bits
! 				PARAMS ((rtx, enum machine_mode, rtx,
! 					 enum machine_mode,
! 					 unsigned HOST_WIDE_INT));
! static unsigned HOST_WIDE_INT nonzero_bits1
! 				PARAMS ((rtx, enum machine_mode, rtx,
! 					 enum machine_mode,
! 					 unsigned HOST_WIDE_INT));
! static unsigned int cached_num_sign_bit_copies
! 				PARAMS ((rtx, enum machine_mode, rtx,
! 					 enum machine_mode, unsigned int));
! static unsigned int num_sign_bit_copies1
! 				PARAMS ((rtx, enum machine_mode, rtx,
! 					 enum machine_mode, unsigned int));
  static int merge_outer_ops	PARAMS ((enum rtx_code *, HOST_WIDE_INT *,
  					 enum rtx_code, HOST_WIDE_INT,
  					 enum machine_mode, int *));
***************
*** 8161,8172 ****
    return x;
  }
  
  /* We let num_sign_bit_copies recur into nonzero_bits as that is useful.
     We don't let nonzero_bits recur into num_sign_bit_copies, because that
     is less useful.  We can't allow both, because that results in exponential
     run time recursion.  There is a nullstone testcase that triggered
     this.  This macro avoids accidental uses of num_sign_bit_copies.  */
! #define num_sign_bit_copies()
  
  /* Given an expression, X, compute which bits in X can be nonzero.
     We don't care about bits outside of those defined in MODE.
--- 8179,8240 ----
    return x;
  }
  
+ #define nonzero_bits_with_known(X, MODE) \
+   cached_nonzero_bits (X, MODE, known_x, known_mode, known_ret)
+ 
+ /* The function cached_nonzero_bits is a wrapper around nonzero_bits1.
+    It avoids exponential behavior in nonzero_bits1 when X has
+    identical subexpressions on the first or the second level.  */
+ 
+ static unsigned HOST_WIDE_INT
+ cached_nonzero_bits (x, mode, known_x, known_mode, known_ret)
+      rtx x;
+      enum machine_mode mode;
+      rtx known_x;
+      enum machine_mode known_mode;
+      unsigned HOST_WIDE_INT known_ret;
+ {
+   if (x == known_x && mode == known_mode)
+     return known_ret;
+ 
+   /* Try to find identical subexpressions.  If found call
+      nonzero_bits1 on X with the subexpressions as KNOWN_X and the
+      precomputed value for the subexpression as KNOWN_RET.  */
+ 
+   if (GET_RTX_CLASS (GET_CODE (x)) == '2'
+       || GET_RTX_CLASS (GET_CODE (x)) == 'c')
+     {
+       rtx x0 = XEXP (x, 0);
+       rtx x1 = XEXP (x, 1);
+ 
+       /* Check the first level.  */
+       if (x0 == x1)
+ 	return nonzero_bits1 (x, mode, x0, mode,
+ 			      nonzero_bits_with_known (x0, mode));
+ 
+       /* Check the second level.  */
+       if ((GET_RTX_CLASS (GET_CODE (x0)) == '2'
+ 	   || GET_RTX_CLASS (GET_CODE (x0)) == 'c')
+ 	  && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
+ 	return nonzero_bits1 (x, mode, x1, mode,
+ 			      nonzero_bits_with_known (x1, mode));
+ 
+       if ((GET_RTX_CLASS (GET_CODE (x1)) == '2'
+ 	   || GET_RTX_CLASS (GET_CODE (x1)) == 'c')
+ 	  && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
+ 	return nonzero_bits1 (x, mode, x0, mode,
+ 			 nonzero_bits_with_known (x0, mode));
+     }
+ 
+   return nonzero_bits1 (x, mode, known_x, known_mode, known_ret);
+ }
+ 
  /* We let num_sign_bit_copies recur into nonzero_bits as that is useful.
     We don't let nonzero_bits recur into num_sign_bit_copies, because that
     is less useful.  We can't allow both, because that results in exponential
     run time recursion.  There is a nullstone testcase that triggered
     this.  This macro avoids accidental uses of num_sign_bit_copies.  */
! #define cached_num_sign_bit_copies()
  
  /* Given an expression, X, compute which bits in X can be nonzero.
     We don't care about bits outside of those defined in MODE.
***************
*** 8175,8183 ****
     a shift, AND, or zero_extract, we can do better.  */
  
  static unsigned HOST_WIDE_INT
! nonzero_bits (x, mode)
       rtx x;
       enum machine_mode mode;
  {
    unsigned HOST_WIDE_INT nonzero = GET_MODE_MASK (mode);
    unsigned HOST_WIDE_INT inner_nz;
--- 8243,8254 ----
     a shift, AND, or zero_extract, we can do better.  */
  
  static unsigned HOST_WIDE_INT
! nonzero_bits1 (x, mode, known_x, known_mode, known_ret)
       rtx x;
       enum machine_mode mode;
+      rtx known_x;
+      enum machine_mode known_mode;
+      unsigned HOST_WIDE_INT known_ret;
  {
    unsigned HOST_WIDE_INT nonzero = GET_MODE_MASK (mode);
    unsigned HOST_WIDE_INT inner_nz;
***************
*** 8215,8221 ****
        && GET_MODE_BITSIZE (GET_MODE (x)) <= HOST_BITS_PER_WIDE_INT
        && GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (GET_MODE (x)))
      {
!       nonzero &= nonzero_bits (x, GET_MODE (x));
        nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (GET_MODE (x));
        return nonzero;
      }
--- 8286,8292 ----
        && GET_MODE_BITSIZE (GET_MODE (x)) <= HOST_BITS_PER_WIDE_INT
        && GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (GET_MODE (x)))
      {
!       nonzero &= nonzero_bits_with_known (x, GET_MODE (x));
        nonzero |= GET_MODE_MASK (mode) & ~GET_MODE_MASK (GET_MODE (x));
        return nonzero;
      }
***************
*** 8297,8303 ****
  			   | ((HOST_WIDE_INT) (-1)
  			      << GET_MODE_BITSIZE (GET_MODE (x))));
  #endif
! 	  return nonzero_bits (tem, mode) & nonzero;
  	}
        else if (nonzero_sign_valid && reg_nonzero_bits[REGNO (x)])
  	{
--- 8368,8374 ----
  			   | ((HOST_WIDE_INT) (-1)
  			      << GET_MODE_BITSIZE (GET_MODE (x))));
  #endif
! 	  return nonzero_bits_with_known (tem, mode) & nonzero;
  	}
        else if (nonzero_sign_valid && reg_nonzero_bits[REGNO (x)])
  	{
***************
*** 8372,8382 ****
        break;
  
      case TRUNCATE:
!       nonzero &= (nonzero_bits (XEXP (x, 0), mode) & GET_MODE_MASK (mode));
        break;
  
      case ZERO_EXTEND:
!       nonzero &= nonzero_bits (XEXP (x, 0), mode);
        if (GET_MODE (XEXP (x, 0)) != VOIDmode)
  	nonzero &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
        break;
--- 8443,8454 ----
        break;
  
      case TRUNCATE:
!       nonzero &= (nonzero_bits_with_known (XEXP (x, 0), mode)
! 		  & GET_MODE_MASK (mode));
        break;
  
      case ZERO_EXTEND:
!       nonzero &= nonzero_bits_with_known (XEXP (x, 0), mode);
        if (GET_MODE (XEXP (x, 0)) != VOIDmode)
  	nonzero &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
        break;
***************
*** 8385,8391 ****
        /* If the sign bit is known clear, this is the same as ZERO_EXTEND.
  	 Otherwise, show all the bits in the outer mode but not the inner
  	 may be nonzero.  */
!       inner_nz = nonzero_bits (XEXP (x, 0), mode);
        if (GET_MODE (XEXP (x, 0)) != VOIDmode)
  	{
  	  inner_nz &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
--- 8457,8463 ----
        /* If the sign bit is known clear, this is the same as ZERO_EXTEND.
  	 Otherwise, show all the bits in the outer mode but not the inner
  	 may be nonzero.  */
!       inner_nz = nonzero_bits_with_known (XEXP (x, 0), mode);
        if (GET_MODE (XEXP (x, 0)) != VOIDmode)
  	{
  	  inner_nz &= GET_MODE_MASK (GET_MODE (XEXP (x, 0)));
***************
*** 8400,8418 ****
        break;
  
      case AND:
!       nonzero &= (nonzero_bits (XEXP (x, 0), mode)
! 		  & nonzero_bits (XEXP (x, 1), mode));
        break;
  
      case XOR:   case IOR:
      case UMIN:  case UMAX:  case SMIN:  case SMAX:
        {
! 	unsigned HOST_WIDE_INT nonzero0 = nonzero_bits (XEXP (x, 0), mode);
  
  	/* Don't call nonzero_bits for the second time if it cannot change
  	   anything.  */
  	if ((nonzero & nonzero0) != nonzero)
! 	  nonzero &= (nonzero0 | nonzero_bits (XEXP (x, 1), mode));
        }
        break;
  
--- 8472,8492 ----
        break;
  
      case AND:
!       nonzero &= (nonzero_bits_with_known (XEXP (x, 0), mode)
! 		  & nonzero_bits_with_known (XEXP (x, 1), mode));
        break;
  
      case XOR:   case IOR:
      case UMIN:  case UMAX:  case SMIN:  case SMAX:
        {
! 	unsigned HOST_WIDE_INT nonzero0 =
! 	  nonzero_bits_with_known (XEXP (x, 0), mode);
  
  	/* Don't call nonzero_bits for the second time if it cannot change
  	   anything.  */
  	if ((nonzero & nonzero0) != nonzero)
! 	  nonzero &= (nonzero0
! 		      | nonzero_bits_with_known (XEXP (x, 1), mode));
        }
        break;
  
***************
*** 8425,8432 ****
  	 computing the width (position of the highest-order nonzero bit)
  	 and the number of low-order zero bits for each value.  */
        {
! 	unsigned HOST_WIDE_INT nz0 = nonzero_bits (XEXP (x, 0), mode);
! 	unsigned HOST_WIDE_INT nz1 = nonzero_bits (XEXP (x, 1), mode);
  	int sign_index = GET_MODE_BITSIZE (GET_MODE (x)) - 1;
  	int width0 = floor_log2 (nz0) + 1;
  	int width1 = floor_log2 (nz1) + 1;
--- 8499,8508 ----
  	 computing the width (position of the highest-order nonzero bit)
  	 and the number of low-order zero bits for each value.  */
        {
! 	unsigned HOST_WIDE_INT nz0 =
! 	  nonzero_bits_with_known (XEXP (x, 0), mode);
! 	unsigned HOST_WIDE_INT nz1 =
! 	  nonzero_bits_with_known (XEXP (x, 1), mode);
  	int sign_index = GET_MODE_BITSIZE (GET_MODE (x)) - 1;
  	int width0 = floor_log2 (nz0) + 1;
  	int width1 = floor_log2 (nz1) + 1;
***************
*** 8511,8517 ****
  
        if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x) > 0)
  	nonzero = (GET_MODE_MASK (GET_MODE (x))
! 		   & nonzero_bits (SUBREG_REG (x), GET_MODE (x)));
  
        /* If the inner mode is a single word for both the host and target
  	 machines, we can compute this from which bits of the inner
--- 8587,8593 ----
  
        if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x) > 0)
  	nonzero = (GET_MODE_MASK (GET_MODE (x))
! 		   & nonzero_bits_with_known (SUBREG_REG (x), GET_MODE (x)));
  
        /* If the inner mode is a single word for both the host and target
  	 machines, we can compute this from which bits of the inner
***************
*** 8520,8526 ****
  	  && (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
  	      <= HOST_BITS_PER_WIDE_INT))
  	{
! 	  nonzero &= nonzero_bits (SUBREG_REG (x), mode);
  
  #if defined (WORD_REGISTER_OPERATIONS) && defined (LOAD_EXTEND_OP)
  	  /* If this is a typical RISC machine, we only have to worry
--- 8596,8602 ----
  	  && (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
  	      <= HOST_BITS_PER_WIDE_INT))
  	{
! 	  nonzero &= nonzero_bits_with_known (SUBREG_REG (x), mode);
  
  #if defined (WORD_REGISTER_OPERATIONS) && defined (LOAD_EXTEND_OP)
  	  /* If this is a typical RISC machine, we only have to worry
***************
*** 8563,8569 ****
  	  unsigned int width = GET_MODE_BITSIZE (inner_mode);
  	  int count = INTVAL (XEXP (x, 1));
  	  unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (inner_mode);
! 	  unsigned HOST_WIDE_INT op_nonzero = nonzero_bits (XEXP (x, 0), mode);
  	  unsigned HOST_WIDE_INT inner = op_nonzero & mode_mask;
  	  unsigned HOST_WIDE_INT outer = 0;
  
--- 8639,8646 ----
  	  unsigned int width = GET_MODE_BITSIZE (inner_mode);
  	  int count = INTVAL (XEXP (x, 1));
  	  unsigned HOST_WIDE_INT mode_mask = GET_MODE_MASK (inner_mode);
! 	  unsigned HOST_WIDE_INT op_nonzero =
! 	    nonzero_bits_with_known (XEXP (x, 0), mode);
  	  unsigned HOST_WIDE_INT inner = op_nonzero & mode_mask;
  	  unsigned HOST_WIDE_INT outer = 0;
  
***************
*** 8621,8628 ****
        break;
  
      case IF_THEN_ELSE:
!       nonzero &= (nonzero_bits (XEXP (x, 1), mode)
! 		  | nonzero_bits (XEXP (x, 2), mode));
        break;
  
      default:
--- 8698,8705 ----
        break;
  
      case IF_THEN_ELSE:
!       nonzero &= (nonzero_bits_with_known (XEXP (x, 1), mode)
! 		  | nonzero_bits_with_known (XEXP (x, 2), mode));
        break;
  
      default:
***************
*** 8633,8649 ****
  }
  
  /* See the macro definition above.  */
! #undef num_sign_bit_copies
  
  /* Return the number of bits at the high-order end of X that are known to
     be equal to the sign bit.  X will be used in mode MODE; if MODE is
     VOIDmode, X will be used in its own mode.  The returned value  will always
     be between 1 and the number of bits in MODE.  */
  
  static unsigned int
! num_sign_bit_copies (x, mode)
       rtx x;
       enum machine_mode mode;
  {
    enum rtx_code code = GET_CODE (x);
    unsigned int bitwidth;
--- 8710,8783 ----
  }
  
  /* See the macro definition above.  */
! #undef cached_num_sign_bit_copies
  
+ #define num_sign_bit_copies_with_known(X, M) \
+   cached_num_sign_bit_copies (X, M, known_x, known_mode, known_ret)
+ 
+ /* The function cached_num_sign_bit_copies is a wrapper around
+    num_sign_bit_copies1.  It avoids exponential behavior in
+    num_sign_bit_copies1 when X has identical subexpressions on the
+    first or the second level.  */
+ 
+ static unsigned int
+ cached_num_sign_bit_copies (x, mode, known_x, known_mode, known_ret)
+      rtx x;
+      enum machine_mode mode;
+      rtx known_x;
+      enum machine_mode known_mode;
+      unsigned int known_ret;
+ {
+   if (x == known_x && mode == known_mode)
+     return known_ret;
+ 
+   /* Try to find identical subexpressions.  If found call
+      num_sign_bit_copies1 on X with the subexpressions as KNOWN_X and
+      the precomputed value for the subexpression as KNOWN_RET.  */
+ 
+   if (GET_RTX_CLASS (GET_CODE (x)) == '2'
+       || GET_RTX_CLASS (GET_CODE (x)) == 'c')
+     {
+       rtx x0 = XEXP (x, 0);
+       rtx x1 = XEXP (x, 1);
+ 
+       /* Check the first level.  */
+       if (x0 == x1)
+ 	return
+ 	  num_sign_bit_copies1 (x, mode, x0, mode,
+ 				num_sign_bit_copies_with_known (x0, mode));
+ 
+       /* Check the second level.  */
+       if ((GET_RTX_CLASS (GET_CODE (x0)) == '2'
+ 	   || GET_RTX_CLASS (GET_CODE (x0)) == 'c')
+ 	  && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
+ 	return
+ 	  num_sign_bit_copies1 (x, mode, x1, mode,
+ 				num_sign_bit_copies_with_known (x1, mode));
+ 
+       if ((GET_RTX_CLASS (GET_CODE (x1)) == '2'
+ 	   || GET_RTX_CLASS (GET_CODE (x1)) == 'c')
+ 	  && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
+ 	return
+ 	  num_sign_bit_copies1 (x, mode, x0, mode,
+ 				num_sign_bit_copies_with_known (x0, mode));
+     }
+ 
+   return num_sign_bit_copies1 (x, mode, known_x, known_mode, known_ret);
+ }
+ 
  /* Return the number of bits at the high-order end of X that are known to
     be equal to the sign bit.  X will be used in mode MODE; if MODE is
     VOIDmode, X will be used in its own mode.  The returned value  will always
     be between 1 and the number of bits in MODE.  */
  
  static unsigned int
! num_sign_bit_copies1 (x, mode, known_x, known_mode, known_ret)
       rtx x;
       enum machine_mode mode;
+      rtx known_x;
+      enum machine_mode known_mode;
+      unsigned int known_ret;
  {
    enum rtx_code code = GET_CODE (x);
    unsigned int bitwidth;
***************
*** 8666,8672 ****
    /* For a smaller object, just ignore the high bits.  */
    if (bitwidth < GET_MODE_BITSIZE (GET_MODE (x)))
      {
!       num0 = num_sign_bit_copies (x, GET_MODE (x));
        return MAX (1,
  		  num0 - (int) (GET_MODE_BITSIZE (GET_MODE (x)) - bitwidth));
      }
--- 8800,8806 ----
    /* For a smaller object, just ignore the high bits.  */
    if (bitwidth < GET_MODE_BITSIZE (GET_MODE (x)))
      {
!       num0 = num_sign_bit_copies_with_known (x, GET_MODE (x));
        return MAX (1,
  		  num0 - (int) (GET_MODE_BITSIZE (GET_MODE (x)) - bitwidth));
      }
***************
*** 8715,8721 ****
  
        tem = get_last_value (x);
        if (tem != 0)
! 	return num_sign_bit_copies (tem, mode);
  
        if (nonzero_sign_valid && reg_sign_bit_copies[REGNO (x)] != 0
  	  && GET_MODE_BITSIZE (GET_MODE (x)) == bitwidth)
--- 8849,8855 ----
  
        tem = get_last_value (x);
        if (tem != 0)
! 	return num_sign_bit_copies_with_known (tem, mode);
  
        if (nonzero_sign_valid && reg_sign_bit_copies[REGNO (x)] != 0
  	  && GET_MODE_BITSIZE (GET_MODE (x)) == bitwidth)
***************
*** 8748,8754 ****
  
        if (SUBREG_PROMOTED_VAR_P (x) && ! SUBREG_PROMOTED_UNSIGNED_P (x))
  	{
! 	  num0 = num_sign_bit_copies (SUBREG_REG (x), mode);
  	  return MAX ((int) bitwidth
  		      - (int) GET_MODE_BITSIZE (GET_MODE (x)) + 1,
  		      num0);
--- 8882,8888 ----
  
        if (SUBREG_PROMOTED_VAR_P (x) && ! SUBREG_PROMOTED_UNSIGNED_P (x))
  	{
! 	  num0 = num_sign_bit_copies_with_known (SUBREG_REG (x), mode);
  	  return MAX ((int) bitwidth
  		      - (int) GET_MODE_BITSIZE (GET_MODE (x)) + 1,
  		      num0);
***************
*** 8757,8763 ****
        /* For a smaller object, just ignore the high bits.  */
        if (bitwidth <= GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x))))
  	{
! 	  num0 = num_sign_bit_copies (SUBREG_REG (x), VOIDmode);
  	  return MAX (1, (num0
  			  - (int) (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
  				   - bitwidth)));
--- 8891,8897 ----
        /* For a smaller object, just ignore the high bits.  */
        if (bitwidth <= GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x))))
  	{
! 	  num0 = num_sign_bit_copies_with_known (SUBREG_REG (x), VOIDmode);
  	  return MAX (1, (num0
  			  - (int) (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
  				   - bitwidth)));
***************
*** 8779,8785 ****
  	   > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
  	  && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (x))) == SIGN_EXTEND
  	  && GET_CODE (SUBREG_REG (x)) == MEM)
! 	return num_sign_bit_copies (SUBREG_REG (x), mode);
  #endif
  #endif
        break;
--- 8913,8919 ----
  	   > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
  	  && LOAD_EXTEND_OP (GET_MODE (SUBREG_REG (x))) == SIGN_EXTEND
  	  && GET_CODE (SUBREG_REG (x)) == MEM)
! 	return num_sign_bit_copies_with_known (SUBREG_REG (x), mode);
  #endif
  #endif
        break;
***************
*** 8791,8806 ****
  
      case SIGN_EXTEND:
        return (bitwidth - GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))
! 	      + num_sign_bit_copies (XEXP (x, 0), VOIDmode));
  
      case TRUNCATE:
        /* For a smaller object, just ignore the high bits.  */
!       num0 = num_sign_bit_copies (XEXP (x, 0), VOIDmode);
        return MAX (1, (num0 - (int) (GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))
  				    - bitwidth)));
  
      case NOT:
!       return num_sign_bit_copies (XEXP (x, 0), mode);
  
      case ROTATE:       case ROTATERT:
        /* If we are rotating left by a number of bits less than the number
--- 8925,8940 ----
  
      case SIGN_EXTEND:
        return (bitwidth - GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))
! 	      + num_sign_bit_copies_with_known (XEXP (x, 0), VOIDmode));
  
      case TRUNCATE:
        /* For a smaller object, just ignore the high bits.  */
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), VOIDmode);
        return MAX (1, (num0 - (int) (GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))
  				    - bitwidth)));
  
      case NOT:
!       return num_sign_bit_copies_with_known (XEXP (x, 0), mode);
  
      case ROTATE:       case ROTATERT:
        /* If we are rotating left by a number of bits less than the number
***************
*** 8810,8816 ****
  	  && INTVAL (XEXP (x, 1)) >= 0
  	  && INTVAL (XEXP (x, 1)) < (int) bitwidth)
  	{
! 	  num0 = num_sign_bit_copies (XEXP (x, 0), mode);
  	  return MAX (1, num0 - (code == ROTATE ? INTVAL (XEXP (x, 1))
  				 : (int) bitwidth - INTVAL (XEXP (x, 1))));
  	}
--- 8944,8950 ----
  	  && INTVAL (XEXP (x, 1)) >= 0
  	  && INTVAL (XEXP (x, 1)) < (int) bitwidth)
  	{
! 	  num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
  	  return MAX (1, num0 - (code == ROTATE ? INTVAL (XEXP (x, 1))
  				 : (int) bitwidth - INTVAL (XEXP (x, 1))));
  	}
***************
*** 8821,8827 ****
  	 is known to be positive, the number of sign bit copies is the
  	 same as that of the input.  Finally, if the input has just one bit
  	 that might be nonzero, all the bits are copies of the sign bit.  */
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
        if (bitwidth > HOST_BITS_PER_WIDE_INT)
  	return num0 > 1 ? num0 - 1 : 1;
  
--- 8955,8961 ----
  	 is known to be positive, the number of sign bit copies is the
  	 same as that of the input.  Finally, if the input has just one bit
  	 that might be nonzero, all the bits are copies of the sign bit.  */
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
        if (bitwidth > HOST_BITS_PER_WIDE_INT)
  	return num0 > 1 ? num0 - 1 : 1;
  
***************
*** 8839,8846 ****
      case SMIN:  case SMAX:  case UMIN:  case UMAX:
        /* Logical operations will preserve the number of sign-bit copies.
  	 MIN and MAX operations always return one of the operands.  */
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies (XEXP (x, 1), mode);
        return MIN (num0, num1);
  
      case PLUS:  case MINUS:
--- 8973,8980 ----
      case SMIN:  case SMAX:  case UMIN:  case UMAX:
        /* Logical operations will preserve the number of sign-bit copies.
  	 MIN and MAX operations always return one of the operands.  */
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies_with_known (XEXP (x, 1), mode);
        return MIN (num0, num1);
  
      case PLUS:  case MINUS:
***************
*** 8858,8865 ****
  		    : bitwidth - floor_log2 (nonzero) - 1);
  	}
  
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies (XEXP (x, 1), mode);
        result = MAX (1, MIN (num0, num1) - 1);
  
  #ifdef POINTERS_EXTEND_UNSIGNED
--- 8992,8999 ----
  		    : bitwidth - floor_log2 (nonzero) - 1);
  	}
  
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies_with_known (XEXP (x, 1), mode);
        result = MAX (1, MIN (num0, num1) - 1);
  
  #ifdef POINTERS_EXTEND_UNSIGNED
***************
*** 8881,8888 ****
  	 to be positive, we must allow for an additional bit since negating
  	 a negative number can remove one sign bit copy.  */
  
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies (XEXP (x, 1), mode);
  
        result = bitwidth - (bitwidth - num0) - (bitwidth - num1);
        if (result > 0
--- 9015,9022 ----
  	 to be positive, we must allow for an additional bit since negating
  	 a negative number can remove one sign bit copy.  */
  
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
!       num1 = num_sign_bit_copies_with_known (XEXP (x, 1), mode);
  
        result = bitwidth - (bitwidth - num0) - (bitwidth - num1);
        if (result > 0
***************
*** 8905,8921 ****
  		& ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
  	return 1;
        else
! 	return num_sign_bit_copies (XEXP (x, 0), mode);
  
      case UMOD:
        /* The result must be <= the second operand.  */
!       return num_sign_bit_copies (XEXP (x, 1), mode);
  
      case DIV:
        /* Similar to unsigned division, except that we have to worry about
  	 the case where the divisor is negative, in which case we have
  	 to add 1.  */
!       result = num_sign_bit_copies (XEXP (x, 0), mode);
        if (result > 1
  	  && (bitwidth > HOST_BITS_PER_WIDE_INT
  	      || (nonzero_bits (XEXP (x, 1), mode)
--- 9039,9055 ----
  		& ((HOST_WIDE_INT) 1 << (bitwidth - 1))) != 0)
  	return 1;
        else
! 	return num_sign_bit_copies_with_known (XEXP (x, 0), mode);
  
      case UMOD:
        /* The result must be <= the second operand.  */
!       return num_sign_bit_copies_with_known (XEXP (x, 1), mode);
  
      case DIV:
        /* Similar to unsigned division, except that we have to worry about
  	 the case where the divisor is negative, in which case we have
  	 to add 1.  */
!       result = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
        if (result > 1
  	  && (bitwidth > HOST_BITS_PER_WIDE_INT
  	      || (nonzero_bits (XEXP (x, 1), mode)
***************
*** 8925,8931 ****
        return result;
  
      case MOD:
!       result = num_sign_bit_copies (XEXP (x, 1), mode);
        if (result > 1
  	  && (bitwidth > HOST_BITS_PER_WIDE_INT
  	      || (nonzero_bits (XEXP (x, 1), mode)
--- 9059,9065 ----
        return result;
  
      case MOD:
!       result = num_sign_bit_copies_with_known (XEXP (x, 1), mode);
        if (result > 1
  	  && (bitwidth > HOST_BITS_PER_WIDE_INT
  	      || (nonzero_bits (XEXP (x, 1), mode)
***************
*** 8937,8943 ****
      case ASHIFTRT:
        /* Shifts by a constant add to the number of bits equal to the
  	 sign bit.  */
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
        if (GET_CODE (XEXP (x, 1)) == CONST_INT
  	  && INTVAL (XEXP (x, 1)) > 0)
  	num0 = MIN ((int) bitwidth, num0 + INTVAL (XEXP (x, 1)));
--- 9071,9077 ----
      case ASHIFTRT:
        /* Shifts by a constant add to the number of bits equal to the
  	 sign bit.  */
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
        if (GET_CODE (XEXP (x, 1)) == CONST_INT
  	  && INTVAL (XEXP (x, 1)) > 0)
  	num0 = MIN ((int) bitwidth, num0 + INTVAL (XEXP (x, 1)));
***************
*** 8951,8962 ****
  	  || INTVAL (XEXP (x, 1)) >= (int) bitwidth)
  	return 1;
  
!       num0 = num_sign_bit_copies (XEXP (x, 0), mode);
        return MAX (1, num0 - INTVAL (XEXP (x, 1)));
  
      case IF_THEN_ELSE:
!       num0 = num_sign_bit_copies (XEXP (x, 1), mode);
!       num1 = num_sign_bit_copies (XEXP (x, 2), mode);
        return MIN (num0, num1);
  
      case EQ:  case NE:  case GE:  case GT:  case LE:  case LT:
--- 9085,9096 ----
  	  || INTVAL (XEXP (x, 1)) >= (int) bitwidth)
  	return 1;
  
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 0), mode);
        return MAX (1, num0 - INTVAL (XEXP (x, 1)));
  
      case IF_THEN_ELSE:
!       num0 = num_sign_bit_copies_with_known (XEXP (x, 1), mode);
!       num1 = num_sign_bit_copies_with_known (XEXP (x, 2), mode);
        return MIN (num0, num1);
  
      case EQ:  case NE:  case GE:  case GT:  case LE:  case LT:
***************
*** 11405,11411 ****
      /* Note that we can't have an "E" in values stored; see
         get_last_value_validate.  */
      if (fmt[i] == 'e')
!       update_table_tick (XEXP (x, i));
  }
  
  /* Record that REG is set to VALUE in insn INSN.  If VALUE is zero, we
--- 11539,11583 ----
      /* Note that we can't have an "E" in values stored; see
         get_last_value_validate.  */
      if (fmt[i] == 'e')
!       {
! 	/* Check for identical subexpressions.  If x contains
! 	   identical subexpression we only have to traverse one of
! 	   them.  */
! 	if (i == 0
! 	    && (GET_RTX_CLASS (code) == '2'
! 		|| GET_RTX_CLASS (code) == 'c'))
! 	  {
! 	    /* Note that at this point x1 has already been
! 	       processed.  */
! 	    rtx x0 = XEXP (x, 0);
! 	    rtx x1 = XEXP (x, 1);
! 
! 	    /* If x0 and x1 are identical then there is no need to
! 	       process x0.  */
! 	    if (x0 == x1)
! 	      break;
! 
! 	    /* If x0 is identical to a subexpression of x1 then while
! 	       processing x1, x0 has already been processed.  Thus we
! 	       are done with x.  */
! 	    if ((GET_RTX_CLASS (GET_CODE (x1)) == '2'
! 		 || GET_RTX_CLASS (GET_CODE (x1)) == 'c')
! 		&& (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
! 	      break;
! 
! 	    /* If x1 is identical to a subexpression of x0 then we
! 	       still have to process the rest of x0.  */
! 	    if ((GET_RTX_CLASS (GET_CODE (x0)) == '2'
! 		 || GET_RTX_CLASS (GET_CODE (x0)) == 'c')
! 		&& (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
! 	      {
! 		update_table_tick (XEXP (x0, x1 == XEXP (x0, 0) ? 1 : 0));
! 		break;
! 	      }
! 	  }
! 	  
! 	update_table_tick (XEXP (x, i));
!       }
  }
  
  /* Record that REG is set to VALUE in insn INSN.  If VALUE is zero, we
***************
*** 11758,11768 ****
      }
  
    for (i = 0; i < len; i++)
!     if ((fmt[i] == 'e'
! 	 && get_last_value_validate (&XEXP (x, i), insn, tick, replace) == 0)
! 	/* Don't bother with these.  They shouldn't occur anyway.  */
! 	|| fmt[i] == 'E')
!       return 0;
  
    /* If we haven't found a reason for it to be invalid, it is valid.  */
    return 1;
--- 11930,11981 ----
      }
  
    for (i = 0; i < len; i++)
!     {
!       if (fmt[i] == 'e')
! 	{
! 	  /* Check for identical subexpressions.  If x contains
! 	     identical subexpression we only have to traverse one of
! 	     them.  */
! 	  if (i == 1
! 	      && (GET_RTX_CLASS (GET_CODE (x)) == '2'
! 		  || GET_RTX_CLASS (GET_CODE (x)) == 'c'))
! 	    {
! 	      /* Note that at this point x0 has already been checked
! 		 and found valid.  */
! 	      rtx x0 = XEXP (x, 0);
! 	      rtx x1 = XEXP (x, 1);
! 
! 	      /* If x0 and x1 are identical then x is also valid.  */
! 	      if (x0 == x1)
! 		return 1;
! 
! 	      /* If x1 is identical to a subexpression of x0 then
! 		 while checking x0, x1 has already been checked.  Thus
! 		 it is valid and so as x.  */
! 	      if ((GET_RTX_CLASS (GET_CODE (x0)) == '2'
! 		   || GET_RTX_CLASS (GET_CODE (x0)) == 'c')
! 		  && (x1 == XEXP (x0, 0) || x1 == XEXP (x0, 1)))
! 		return 1;
! 
! 	      /* If x0 is identical to a subexpression of x1 then x is
! 		 valid iff the rest of x1 is valid.  */
! 	      if ((GET_RTX_CLASS (GET_CODE (x1)) == '2'
! 		   || GET_RTX_CLASS (GET_CODE (x1)) == 'c')
! 		  && (x0 == XEXP (x1, 0) || x0 == XEXP (x1, 1)))
! 		return
! 		  get_last_value_validate (&XEXP (x1,
! 						  x0 == XEXP (x1, 0) ? 1 : 0),
! 					   insn, tick, replace);
! 	    }
! 
! 	  if (get_last_value_validate (&XEXP (x, i), insn, tick,
! 				       replace) == 0)
! 	    return 0;
! 	}
!       /* Don't bother with these.  They shouldn't occur anyway.  */
!       else if (fmt[i] == 'E')
! 	return 0;
!     }
  
    /* If we haven't found a reason for it to be invalid, it is valid.  */
    return 1;


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