public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Introduce int_const_binop_1, obsolete notrunc parameter of int_const_binop
@ 2007-01-10 16:04 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2007-01-10 16:04 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]

This is the last patch before the patch that enhances VRP to produce more
anti-ranges if possible.  It introduces int_const_binop_1 split out
from int_const_binop.

int_const_binop_1 takes a result type and extra output arguments for the
components of the double-int result.  It also returns the overflow status from
the individual double helpers.  This allows access to overflow (and overflow
due to truncating via fit_double_type) and avoids creating a tree node in
some cases.

I also took the opportunity to obsolete the notrunc parameter of
int_const_binop,
only very few callers used it.  This avoids remembering non-canonical integer
constants.  A followup patch can remove the unused parameter.

The patch also prepares VRP so the next patch will get smaller.

Bootstrapped and tested on x86_64-unknown-linux-gnu, compared to
yesterday there's one acats FAIL less - but I wouldn't attribute this
to this patch.

I will apply this after Roger applied the TREE_CONSTANT_OVERFLOW patch.

Thanks,
Richard.

2007-01-10  Richard Guenther  <rguenther@suse.de>

        * tree.h (int_const_binop_1): Export.
        * fold-const.c (int_const_binop_1): New function split
        out from int_const_binop.
        (int_const_binop): Use int_const_binop_1, always truncate
        to type precision.
        * tree-vrp.c (vrp_int_const_binop): Simplify by using
        int_const_binop_1.
        (extract_range_from_binary_expr): Separate MIN/MAX_EXPR
        handling, merge PLUS/MINUS_EXPR handling.
        * tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Do
        not set notrunc for int_const_binop.
        (maybe_fold_stmt_indirect): Likewise.
        * tree-sra.c (instantiate_missing_elements): Likewise.
        (generate_element_init_1): Likewise.
        * tree-cfg.c (group_case_labels): Don't needlessly build
        an integer constant tree node, use int_const_binop_1 instead.

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 21653 bytes --]

2007-01-10  Richard Guenther  <rguenther@suse.de>

	* tree.h (int_const_binop_1): Export.
	* fold-const.c (int_const_binop_1): New function split
	out from int_const_binop.
	(int_const_binop): Use int_const_binop_1, always truncate
	to type precision.
	* tree-vrp.c (vrp_int_const_binop): Simplify by using
	int_const_binop_1.
	(extract_range_from_binary_expr): Separate MIN/MAX_EXPR
	handling, merge PLUS/MINUS_EXPR handling.
	* tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Do
	not set notrunc for int_const_binop.
	(maybe_fold_stmt_indirect): Likewise.
	* tree-sra.c (instantiate_missing_elements): Likewise. 
	(generate_element_init_1): Likewise.
	* tree-cfg.c (group_case_labels): Don't needlessly build
	an integer constant tree node, use int_const_binop_1 instead.

Index: tree-vrp.c
===================================================================
*** tree-vrp.c.orig	2007-01-10 10:51:46.000000000 +0100
--- tree-vrp.c	2007-01-10 10:52:40.000000000 +0100
*************** extract_range_from_ssa_name (value_range
*** 1208,1301 ****
  static inline tree
  vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
  {
!   tree res;
  
!   res = int_const_binop (code, val1, val2, 0);
! 
!   /* If we are not using wrapping arithmetic, operate symbolically
!      on -INF and +INF.  */
    if (TYPE_UNSIGNED (TREE_TYPE (val1))
        || flag_wrapv)
!     {
!       int checkz = compare_values (res, val1);
!       bool overflow = false;
! 
!       /* Ensure that res = val1 [+*] val2 >= val1
!          or that res = val1 - val2 <= val1.  */
!       if ((code == PLUS_EXPR
! 	   && !(checkz == 1 || checkz == 0))
!           || (code == MINUS_EXPR
! 	      && !(checkz == 0 || checkz == -1)))
! 	{
! 	  overflow = true;
! 	}
!       /* Checking for multiplication overflow is done by dividing the
! 	 output of the multiplication by the first input of the
! 	 multiplication.  If the result of that division operation is
! 	 not equal to the second input of the multiplication, then the
! 	 multiplication overflowed.  */
!       else if (code == MULT_EXPR && !integer_zerop (val1))
! 	{
! 	  tree tmp = int_const_binop (TRUNC_DIV_EXPR,
! 				      res,
! 				      val1, 0);
! 	  int check = compare_values (tmp, val2);
! 
! 	  if (check != 0)
! 	    overflow = true;
! 	}
! 
!       if (overflow)
! 	{
! 	  res = copy_node (res);
! 	  TREE_OVERFLOW (res) = 1;
! 	}
! 
!     }
!   else if (TREE_OVERFLOW (res)
! 	   && !TREE_OVERFLOW (val1)
! 	   && !TREE_OVERFLOW (val2))
!     {
!       /* If the operation overflowed but neither VAL1 nor VAL2 are
! 	 overflown, return -INF or +INF depending on the operation
! 	 and the combination of signs of the operands.  */
!       int sgn1 = tree_int_cst_sgn (val1);
!       int sgn2 = tree_int_cst_sgn (val2);
! 
!       /* Notice that we only need to handle the restricted set of
! 	 operations handled by extract_range_from_binary_expr.
! 	 Among them, only multiplication, addition and subtraction
! 	 can yield overflow without overflown operands because we
! 	 are working with integral types only... except in the
! 	 case VAL1 = -INF and VAL2 = -1 which overflows to +INF
! 	 for division too.  */
! 
!       /* For multiplication, the sign of the overflow is given
! 	 by the comparison of the signs of the operands.  */
!       if ((code == MULT_EXPR && sgn1 == sgn2)
!           /* For addition, the operands must be of the same sign
! 	     to yield an overflow.  Its sign is therefore that
! 	     of one of the operands, for example the first.  */
! 	  || (code == PLUS_EXPR && sgn1 > 0)
! 	  /* For subtraction, the operands must be of different
! 	     signs to yield an overflow.  Its sign is therefore
! 	     that of the first operand or the opposite of that
! 	     of the second operand.  A first operand of 0 counts
! 	     as positive here, for the corner case 0 - (-INF),
! 	     which overflows, but must yield +INF.  */
! 	  || (code == MINUS_EXPR && sgn1 >= 0)
! 	  /* For division, the only case is -INF / -1 = +INF.  */
! 	  || code == TRUNC_DIV_EXPR
! 	  || code == FLOOR_DIV_EXPR
! 	  || code == CEIL_DIV_EXPR
! 	  || code == EXACT_DIV_EXPR
! 	  || code == ROUND_DIV_EXPR)
! 	return TYPE_MAX_VALUE (TREE_TYPE (res));
!       else
! 	return TYPE_MIN_VALUE (TREE_TYPE (res));
!     }
  
!   return res;
  }
  
  
--- 1208,1272 ----
  static inline tree
  vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
  {
!   unsigned HOST_WIDE_INT low;
!   HOST_WIDE_INT high;
!   bool overflow;
!   int sgn1, sgn2;
! 
!   /* We sometimes have constants with TREE_OVERFLOW set in the IL
!      that end up as value range bounds.  Don't get confused by them
!      here.  */
!   overflow = int_const_binop_1 (code, TREE_TYPE (val1), val1, val2,
! 				&low, &high);
!   overflow |= fit_double_type (low, high, &low, &high, TREE_TYPE (val1));
! 
!   /* If there was no overflow return the result.  */
!   if (!overflow)
!     return build_int_cst_wide (TREE_TYPE (val1), low, high);
  
!   /* If we are using wrapping arithmetic return the result with
!      the overflow flag set.  */
    if (TYPE_UNSIGNED (TREE_TYPE (val1))
        || flag_wrapv)
!     return force_fit_type_double (TREE_TYPE (val1), low, high,
! 				  0, overflow, false);
  
!   /* If we are not using wrapping arithmetic, return -INF or +INF
!      depending on the direction of overflow.  */
!   sgn1 = tree_int_cst_sgn (val1);
!   sgn2 = tree_int_cst_sgn (val2);
! 
!   /* Notice that we only need to handle the restricted set of
!      operations handled by extract_range_from_binary_expr.
!      Among them, only multiplication, addition and subtraction
!      can yield overflow without overflown operands because we
!      are working with integral types only... except in the
!      case VAL1 = -INF and VAL2 = -1 which overflows to +INF
!      for division too.  */
! 
!   /* For multiplication, the sign of the overflow is given
!      by the comparison of the signs of the operands.  */
!   if ((code == MULT_EXPR && sgn1 == sgn2)
!       /* For addition, the operands must be of the same sign
!          to yield an overflow.  Its sign is therefore that
!          of one of the operands, for example the first.  */
!       || (code == PLUS_EXPR && sgn1 > 0)
!       /* For subtraction, the operands must be of different
!          signs to yield an overflow.  Its sign is therefore
!          that of the first operand or the opposite of that
!          of the second operand.  A first operand of 0 counts
! 	 as positive here, for the corner case 0 - (-INF),
! 	 which overflows, but must yield +INF.  */
!       || (code == MINUS_EXPR && sgn1 >= 0)
!       /* For division, the only case is -INF / -1 = +INF.  */
!       || code == TRUNC_DIV_EXPR
!       || code == FLOOR_DIV_EXPR
!       || code == CEIL_DIV_EXPR
!       || code == EXACT_DIV_EXPR
!       || code == ROUND_DIV_EXPR)
!     return TYPE_MAX_VALUE (TREE_TYPE (val1));
!   else
!     return TYPE_MIN_VALUE (TREE_TYPE (val1));
  }
  
  
*************** extract_range_from_binary_expr (value_ra
*** 1459,1486 ****
  	  return;
  	}
      }
!   else if (code == PLUS_EXPR
! 	   || code == MIN_EXPR
  	   || code == MAX_EXPR)
      {
!       /* If we have a PLUS_EXPR with two VR_ANTI_RANGEs, drop to
  	 VR_VARYING.  It would take more effort to compute a precise
  	 range for such a case.  For example, if we have op0 == 1 and
  	 op1 == -1 with their ranges both being ~[0,0], we would have
  	 op0 + op1 == 0, so we cannot claim that the sum is in ~[0,0].
  	 Note that we are guaranteed to have vr0.type == vr1.type at
  	 this point.  */
!       if (code == PLUS_EXPR && vr0.type == VR_ANTI_RANGE)
  	{
  	  set_value_range_to_varying (vr);
  	  return;
  	}
  
!       /* For operations that make the resulting range directly
! 	 proportional to the original ranges, apply the operation to
! 	 the same end of each range.  */
!       min = vrp_int_const_binop (code, vr0.min, vr1.min);
!       max = vrp_int_const_binop (code, vr0.max, vr1.max);
      }
    else if (code == MULT_EXPR
  	   || code == TRUNC_DIV_EXPR
--- 1430,1475 ----
  	  return;
  	}
      }
!   else if (code == MIN_EXPR
  	   || code == MAX_EXPR)
      {
!       /* For operations that make the resulting range directly
! 	 proportional to the original ranges, apply the operation to
! 	 the same end of each range.  */
!       min = int_const_binop (code, vr0.min, vr1.min, 0);
!       max = int_const_binop (code, vr0.max, vr1.max, 0);
!     }
!   else if (code == PLUS_EXPR
! 	   || code == MINUS_EXPR)
!     {
!       /* If we have a PLUS/MINUS_EXPR with two VR_ANTI_RANGEs, drop to
  	 VR_VARYING.  It would take more effort to compute a precise
  	 range for such a case.  For example, if we have op0 == 1 and
  	 op1 == -1 with their ranges both being ~[0,0], we would have
  	 op0 + op1 == 0, so we cannot claim that the sum is in ~[0,0].
  	 Note that we are guaranteed to have vr0.type == vr1.type at
  	 this point.  */
!       if (vr0.type == VR_ANTI_RANGE)
  	{
  	  set_value_range_to_varying (vr);
  	  return;
  	}
  
!       if (code == PLUS_EXPR)
!         {
! 	  /* For operations that make the resulting range directly
! 	     proportional to the original ranges, apply the operation to
! 	     the same end of each range.  */
! 	  min = vrp_int_const_binop (code, vr0.min, vr1.min);
! 	  max = vrp_int_const_binop (code, vr0.max, vr1.max);
! 	}
!       else
!         {
! 	  /* For MINUS_EXPR, apply the operation to the opposite ends of
! 	     each range.  */
! 	  min = vrp_int_const_binop (code, vr0.min, vr1.max);
! 	  max = vrp_int_const_binop (code, vr0.max, vr1.min);
! 	}
      }
    else if (code == MULT_EXPR
  	   || code == TRUNC_DIV_EXPR
*************** extract_range_from_binary_expr (value_ra
*** 1573,1598 ****
  	    }
  	}
      }
-   else if (code == MINUS_EXPR)
-     {
-       /* If we have a MINUS_EXPR with two VR_ANTI_RANGEs, drop to
- 	 VR_VARYING.  It would take more effort to compute a precise
- 	 range for such a case.  For example, if we have op0 == 1 and
- 	 op1 == 1 with their ranges both being ~[0,0], we would have
- 	 op0 - op1 == 0, so we cannot claim that the difference is in
- 	 ~[0,0].  Note that we are guaranteed to have
- 	 vr0.type == vr1.type at this point.  */
-       if (vr0.type == VR_ANTI_RANGE)
- 	{
- 	  set_value_range_to_varying (vr);
- 	  return;
- 	}
- 
-       /* For MINUS_EXPR, apply the operation to the opposite ends of
- 	 each range.  */
-       min = vrp_int_const_binop (code, vr0.min, vr1.max);
-       max = vrp_int_const_binop (code, vr0.max, vr1.min);
-     }
    else if (code == BIT_AND_EXPR)
      {
        if (vr0.type == VR_RANGE
--- 1562,1567 ----
Index: tree.h
===================================================================
*** tree.h.orig	2007-01-10 10:51:46.000000000 +0100
--- tree.h	2007-01-10 10:52:40.000000000 +0100
*************** extern tree fold_truth_not_expr (tree);
*** 4374,4379 ****
--- 4374,4381 ----
  extern tree fold_unary_to_constant (enum tree_code, tree, tree);
  extern tree fold_binary_to_constant (enum tree_code, tree, tree, tree);
  extern tree fold_read_from_constant_string (tree);
+ extern bool int_const_binop_1 (enum tree_code, tree, tree, tree,
+ 			       unsigned HOST_WIDE_INT *, HOST_WIDE_INT *);
  extern tree int_const_binop (enum tree_code, tree, tree, int);
  extern tree build_fold_addr_expr (tree);
  extern tree fold_build_cleanup_point_expr (tree type, tree expr);
Index: fold-const.c
===================================================================
*** fold-const.c.orig	2007-01-10 10:51:46.000000000 +0100
--- fold-const.c	2007-01-10 10:52:40.000000000 +0100
*************** int_binop_types_match_p (enum tree_code 
*** 1452,1466 ****
  	 && TYPE_MODE (type1) == TYPE_MODE (type2);
  }
  
  
! /* Combine two integer constants ARG1 and ARG2 under operation CODE
!    to produce a new constant.  Return NULL_TREE if we don't know how
!    to evaluate CODE at compile-time.
! 
!    If NOTRUNC is nonzero, do not truncate the result to fit the data type.  */
! 
! tree
! int_const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
  {
    unsigned HOST_WIDE_INT int1l, int2l;
    HOST_WIDE_INT int1h, int2h;
--- 1452,1467 ----
  	 && TYPE_MODE (type1) == TYPE_MODE (type2);
  }
  
+ /* Helper of int_const_binop.  Computes ARG1 CODE ARG2 in type TYPE
+    storing the result in the double integer *HV:*LV without truncating
+    it to the precision of TYPE.  Returns true if the operation overflowed
+    the precision of a double integer, false otherwise.  You need to use
+    fit_double_type to query if the operation overflowed the precision
+    of TYPE.  */
  
! bool
! int_const_binop_1 (enum tree_code code, tree type, tree arg1, tree arg2,
! 		   unsigned HOST_WIDE_INT *lv, HOST_WIDE_INT *hv)
  {
    unsigned HOST_WIDE_INT int1l, int2l;
    HOST_WIDE_INT int1h, int2h;
*************** int_const_binop (enum tree_code code, tr
*** 1468,1478 ****
    HOST_WIDE_INT hi;
    unsigned HOST_WIDE_INT garbagel;
    HOST_WIDE_INT garbageh;
-   tree t;
-   tree type = TREE_TYPE (arg1);
    int uns = TYPE_UNSIGNED (type);
-   int is_sizetype
-     = (TREE_CODE (type) == INTEGER_TYPE && TYPE_IS_SIZETYPE (type));
    int overflow = 0;
  
    int1l = TREE_INT_CST_LOW (arg1);
--- 1469,1475 ----
*************** int_const_binop (enum tree_code code, tr
*** 1545,1551 ****
  
      case ROUND_DIV_EXPR:
        if (int2h == 0 && int2l == 0)
! 	return NULL_TREE;
        if (int2h == 0 && int2l == 1)
  	{
  	  low = int1l, hi = int1h;
--- 1542,1548 ----
  
      case ROUND_DIV_EXPR:
        if (int2h == 0 && int2l == 0)
! 	return 1;
        if (int2h == 0 && int2l == 1)
  	{
  	  low = int1l, hi = int1h;
*************** int_const_binop (enum tree_code code, tr
*** 1579,1585 ****
  
      case ROUND_MOD_EXPR:
        if (int2h == 0 && int2l == 0)
! 	return NULL_TREE;
        overflow = div_and_round_double (code, uns,
  				       int1l, int1h, int2l, int2h,
  				       &garbagel, &garbageh, &low, &hi);
--- 1576,1582 ----
  
      case ROUND_MOD_EXPR:
        if (int2h == 0 && int2l == 0)
! 	return 1;
        overflow = div_and_round_double (code, uns,
  				       int1l, int1h, int2l, int2h,
  				       &garbagel, &garbageh, &low, &hi);
*************** int_const_binop (enum tree_code code, tr
*** 1604,1636 ****
        break;
  
      default:
!       return NULL_TREE;
      }
  
!   if (notrunc)
      {
!       t = build_int_cst_wide (TREE_TYPE (arg1), low, hi);
  
!       /* Propagate overflow flags ourselves.  */
!       if (((!uns || is_sizetype) && overflow)
! 	  | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2))
! 	{
! 	  t = copy_node (t);
! 	  TREE_OVERFLOW (t) = 1;
! 	  TREE_CONSTANT_OVERFLOW (t) = 1;
! 	}
!       else if (TREE_CONSTANT_OVERFLOW (arg1) | TREE_CONSTANT_OVERFLOW (arg2))
! 	{
! 	  t = copy_node (t);
! 	  TREE_CONSTANT_OVERFLOW (t) = 1;
! 	}
      }
!   else
!     t = force_fit_type_double (TREE_TYPE (arg1), low, hi, 1,
! 			       ((!uns || is_sizetype) && overflow)
! 			       | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2),
! 			       TREE_CONSTANT_OVERFLOW (arg1)
! 			       | TREE_CONSTANT_OVERFLOW (arg2));
  
    return t;
  }
--- 1601,1680 ----
        break;
  
      default:
!       gcc_unreachable ();
      }
  
!   *lv = low;
!   *hv = hi;
! 
!   return overflow != 0;
! }
! 
! /* Combine two integer constants ARG1 and ARG2 under operation CODE
!    to produce a new constant.  Return NULL_TREE if we don't know how
!    to evaluate CODE at compile-time.
! 
!    The result is truncated to fit the data type of ARG1 and the
!    TREE_OVERFLOW flag is set according to the operation, overflow flags
!    of ARG1 and ARG2 and the signedness of the operands.  */
! 
! tree
! int_const_binop (enum tree_code code, tree arg1, tree arg2,
! 		 int notrunc ATTRIBUTE_UNUSED)
! {
!   unsigned HOST_WIDE_INT low;
!   HOST_WIDE_INT hi;
!   tree t;
!   tree type = TREE_TYPE (arg1);
!   int uns = TYPE_UNSIGNED (type);
!   int is_sizetype
!     = (TREE_CODE (type) == INTEGER_TYPE && TYPE_IS_SIZETYPE (type));
!   int overflow;
! 
!   gcc_assert (notrunc == 0);
! 
!   /* We have to fail gracefully for unhandled tree codes and some
!      special cases.  Keep this list in sync with int_const_binop_1.  */
!   switch (code)
      {
!     case BIT_IOR_EXPR:
!     case BIT_XOR_EXPR:
!     case BIT_AND_EXPR:
!     case RSHIFT_EXPR:
!     case LSHIFT_EXPR:
!     case RROTATE_EXPR:
!     case LROTATE_EXPR:
!     case PLUS_EXPR:
!     case MINUS_EXPR:
!     case MULT_EXPR:
!     case MIN_EXPR:
!     case MAX_EXPR:
!       break;
  
!     case TRUNC_DIV_EXPR:
!     case FLOOR_DIV_EXPR:
!     case CEIL_DIV_EXPR:
!     case EXACT_DIV_EXPR:
!     case ROUND_DIV_EXPR:
!     case TRUNC_MOD_EXPR:
!     case FLOOR_MOD_EXPR:
!     case CEIL_MOD_EXPR:
!     case ROUND_MOD_EXPR:
!       if (integer_zerop (arg2))
! 	return NULL_TREE;
!       break;
! 
!     default:
!       return NULL_TREE;
      }
! 
!   overflow = int_const_binop_1 (code, type, arg1, arg2, &low, &hi);
! 
!   t = force_fit_type_double (type, low, hi, 1,
! 			     ((!uns || is_sizetype) && overflow)
! 			     | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2),
! 			     TREE_CONSTANT_OVERFLOW (arg1)
! 			     | TREE_CONSTANT_OVERFLOW (arg2));
  
    return t;
  }
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c.orig	2007-01-10 10:51:46.000000000 +0100
--- tree-ssa-ccp.c	2007-01-10 10:52:40.000000000 +0100
*************** maybe_fold_offset_to_component_ref (tree
*** 1715,1721 ****
        if (!DECL_SIZE_UNIT (f)
  	  || TREE_CODE (DECL_SIZE_UNIT (f)) != INTEGER_CST)
  	continue;
!       t = int_const_binop (MINUS_EXPR, offset, field_offset, 1);
        if (!tree_int_cst_lt (t, DECL_SIZE_UNIT (f)))
  	continue;
  
--- 1715,1721 ----
        if (!DECL_SIZE_UNIT (f)
  	  || TREE_CODE (DECL_SIZE_UNIT (f)) != INTEGER_CST)
  	continue;
!       t = int_const_binop (MINUS_EXPR, offset, field_offset, 0);
        if (!tree_int_cst_lt (t, DECL_SIZE_UNIT (f)))
  	continue;
  
*************** maybe_fold_offset_to_component_ref (tree
*** 1730,1736 ****
  
    f = tail_array_field;
    field_type = TREE_TYPE (f);
!   offset = int_const_binop (MINUS_EXPR, offset, byte_position (f), 1);
  
   found:
    /* If we get here, we've got an aggregate field, and a possibly 
--- 1730,1736 ----
  
    f = tail_array_field;
    field_type = TREE_TYPE (f);
!   offset = int_const_binop (MINUS_EXPR, offset, byte_position (f), 0);
  
   found:
    /* If we get here, we've got an aggregate field, and a possibly 
*************** maybe_fold_stmt_indirect (tree expr, tre
*** 1777,1783 ****
  	return NULL_TREE;
        base = TREE_OPERAND (base, 0);
  
!       offset = int_const_binop (PLUS_EXPR, offset, offset2, 1);
      }
  
    if (TREE_CODE (base) == ADDR_EXPR)
--- 1777,1785 ----
  	return NULL_TREE;
        base = TREE_OPERAND (base, 0);
  
!       offset = int_const_binop (PLUS_EXPR, offset, offset2, 0);
!       if (TREE_OVERFLOW (offset))
! 	return NULL_TREE;
      }
  
    if (TREE_CODE (base) == ADDR_EXPR)
Index: tree-sra.c
===================================================================
*** tree-sra.c.orig	2007-01-10 10:51:46.000000000 +0100
--- tree-sra.c	2007-01-10 10:52:40.000000000 +0100
*************** instantiate_missing_elements (struct sra
*** 1352,1358 ****
  	    instantiate_missing_elements_1 (elt, i, subtype);
  	    if (tree_int_cst_equal (i, max))
  	      break;
! 	    i = int_const_binop (PLUS_EXPR, i, integer_one_node, true);
  	  }
  
  	break;
--- 1352,1358 ----
  	    instantiate_missing_elements_1 (elt, i, subtype);
  	    if (tree_int_cst_equal (i, max))
  	      break;
! 	    i = int_const_binop (PLUS_EXPR, i, integer_one_node, 0);
  	  }
  
  	break;
*************** generate_element_init_1 (struct sra_elt 
*** 1864,1870 ****
  		  if (tree_int_cst_equal (lower, upper))
  		    break;
  		  lower = int_const_binop (PLUS_EXPR, lower,
! 					   integer_one_node, true);
  		}
  	    }
  	  else
--- 1864,1870 ----
  		  if (tree_int_cst_equal (lower, upper))
  		    break;
  		  lower = int_const_binop (PLUS_EXPR, lower,
! 					   integer_one_node, 0);
  		}
  	    }
  	  else
Index: tree-cfg.c
===================================================================
*** tree-cfg.c.orig	2007-01-10 10:51:46.000000000 +0100
--- tree-cfg.c	2007-01-10 10:52:57.000000000 +0100
*************** group_case_labels (void)
*** 1122,1134 ****
  		{
  		  tree merge_case = TREE_VEC_ELT (labels, i);
  	          tree merge_label = CASE_LABEL (merge_case);
! 		  tree t = int_const_binop (PLUS_EXPR, base_high,
! 					    integer_one_node, 1);
  
  		  /* Merge the cases if they jump to the same place,
  		     and their ranges are consecutive.  */
  		  if (merge_label == base_label
! 		      && tree_int_cst_equal (CASE_LOW (merge_case), t))
  		    {
  		      base_high = CASE_HIGH (merge_case) ?
  			CASE_HIGH (merge_case) : CASE_LOW (merge_case);
--- 1122,1138 ----
  		{
  		  tree merge_case = TREE_VEC_ELT (labels, i);
  	          tree merge_label = CASE_LABEL (merge_case);
! 		  unsigned HOST_WIDE_INT tl;
! 		  HOST_WIDE_INT th;
  
  		  /* Merge the cases if they jump to the same place,
  		     and their ranges are consecutive.  */
  		  if (merge_label == base_label
! 		      && !int_const_binop_1 (PLUS_EXPR, TREE_TYPE (base_high),
! 					     base_high, integer_one_node,
! 					     &tl, &th)
! 		      && TREE_INT_CST_LOW (CASE_LOW (merge_case)) == tl
! 		      && TREE_INT_CST_HIGH (CASE_LOW (merge_case)) == th)
  		    {
  		      base_high = CASE_HIGH (merge_case) ?
  			CASE_HIGH (merge_case) : CASE_LOW (merge_case);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-01-10 16:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-10 16:04 [PATCH] Introduce int_const_binop_1, obsolete notrunc parameter of int_const_binop Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).