summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-28 18:23:16 +0000
committeraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-28 18:23:16 +0000
commitd3237426929c302bcab9d683353b041667b22488 (patch)
tree4667776860379c311babeb25f863259e7d46dbc0
parentf343b8e8f2730a69ddc966204e4b83406966c0b0 (diff)
downloadgcc-d3237426929c302bcab9d683353b041667b22488.tar.gz
* double-int.h (force_fit_type_double): Remove declaration.
* double-int.c (force_fit_type_double): Move to tree.c. * tree.h (force_fit_type_double): Declare. * tree.h (force_fit_type_double): Moved from double-int.c. Use double_int type for 'cst' argument. Use double_int_fits_to_tree_p and double_int_to_tree instead of fit_double_type and build_int_cst_wide. * convert.c (convert_to_pointer): Adjust call to force_fit_type_double. * tree-vrp.c (extract_range_from_assert, extract_range_from_unary_expr): Adjust call to force_fit_type_double. * fold-const.c: Update comment. (int_const_binop, fold_convert_const_int_from_int, fold_convert_const_int_from_real, fold_convert_const_int_from_fixed, extract_muldiv_1, fold_div_compare, fold_sign_changed_comparison, fold_unary_loc, fold_negate_const, fold_abs_const, fold_not_const, round_up_loc): Adjust call to force_fit_type_double. /c-family * c-common.c (shorten_compare): Adjust call to force_fit_type_double. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161509 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/c-family/ChangeLog4
-rw-r--r--gcc/c-family/c-common.c5
-rw-r--r--gcc/convert.c3
-rw-r--r--gcc/double-int.c50
-rw-r--r--gcc/double-int.h2
-rw-r--r--gcc/fold-const.c122
-rw-r--r--gcc/tree-vrp.c16
-rw-r--r--gcc/tree.c46
-rw-r--r--gcc/tree.h1
10 files changed, 134 insertions, 134 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ce28e609002..188a5ef838d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+2010-06-28 Anatoly Sokolov <aesok@post.ru>
+
+ * double-int.h (force_fit_type_double): Remove declaration.
+ * double-int.c (force_fit_type_double): Move to tree.c.
+ * tree.h (force_fit_type_double): Declare.
+ * tree.h (force_fit_type_double): Moved from double-int.c. Use
+ double_int type for 'cst' argument. Use double_int_fits_to_tree_p and
+ double_int_to_tree instead of fit_double_type and build_int_cst_wide.
+ * convert.c (convert_to_pointer): Adjust call to
+ force_fit_type_double.
+ * tree-vrp.c (extract_range_from_assert,
+ extract_range_from_unary_expr): Adjust call to force_fit_type_double.
+ * fold-const.c: Update comment.
+ (int_const_binop, fold_convert_const_int_from_int,
+ fold_convert_const_int_from_real, fold_convert_const_int_from_fixed,
+ extract_muldiv_1, fold_div_compare, fold_sign_changed_comparison,
+ fold_unary_loc, fold_negate_const, fold_abs_const, fold_not_const,
+ round_up_loc): Adjust call to force_fit_type_double.
+
2010-06-28 Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
* config/rs6000/rs6000.h (PROCESSOR_TITAN): Declare.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 5b575ee1b3d..276b49e8650 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-28 Anatoly Sokolov <aesok@post.ru>
+
+ * c-common.c (shorten_compare): Adjust call to force_fit_type_double.
+
2010-06-28 Steven Bosscher <steven@gcc.gnu.org>
* c-cppbuiltin.c: Do not include except.h.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 14675bcf67e..3393093cc9e 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3361,9 +3361,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
/* Convert primop1 to target type, but do not introduce
additional overflow. We know primop1 is an int_cst. */
primop1 = force_fit_type_double (*restype_ptr,
- TREE_INT_CST_LOW (primop1),
- TREE_INT_CST_HIGH (primop1), 0,
- TREE_OVERFLOW (primop1));
+ tree_to_double_int (primop1),
+ 0, TREE_OVERFLOW (primop1));
}
if (type != *restype_ptr)
{
diff --git a/gcc/convert.c b/gcc/convert.c
index 436fb2a6587..f54b6d9adfe 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -46,7 +46,8 @@ convert_to_pointer (tree type, tree expr)
/* Propagate overflow to the NULL pointer. */
if (integer_zerop (expr))
- return force_fit_type_double (type, 0, 0, 0, TREE_OVERFLOW (expr));
+ return force_fit_type_double (type, double_int_zero, 0,
+ TREE_OVERFLOW (expr));
switch (TREE_CODE (TREE_TYPE (expr)))
{
diff --git a/gcc/double-int.c b/gcc/double-int.c
index 7bdda7da212..aa175e89d41 100644
--- a/gcc/double-int.c
+++ b/gcc/double-int.c
@@ -134,56 +134,6 @@ fit_double_type (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1,
return l1 != low0 || h1 != high0;
}
-/* We force the double-int HIGH:LOW to the range of the type TYPE by
- sign or zero extending it.
- OVERFLOWABLE indicates if we are interested
- in overflow of the value, when >0 we are only interested in signed
- overflow, for <0 we are interested in any overflow. OVERFLOWED
- indicates whether overflow has already occurred. CONST_OVERFLOWED
- indicates whether constant overflow has already occurred. We force
- T's value to be within range of T's type (by setting to 0 or 1 all
- the bits outside the type's range). We set TREE_OVERFLOWED if,
- OVERFLOWED is nonzero,
- or OVERFLOWABLE is >0 and signed overflow occurs
- or OVERFLOWABLE is <0 and any overflow occurs
- We return a new tree node for the extended double-int. The node
- is shared if no overflow flags are set. */
-
-tree
-force_fit_type_double (tree type, unsigned HOST_WIDE_INT low,
- HOST_WIDE_INT high, int overflowable,
- bool overflowed)
-{
- int sign_extended_type;
- bool overflow;
-
- /* Size types *are* sign extended. */
- sign_extended_type = (!TYPE_UNSIGNED (type)
- || (TREE_CODE (type) == INTEGER_TYPE
- && TYPE_IS_SIZETYPE (type)));
-
- overflow = fit_double_type (low, high, &low, &high, type);
-
- /* If we need to set overflow flags, return a new unshared node. */
- if (overflowed || overflow)
- {
- if (overflowed
- || overflowable < 0
- || (overflowable > 0 && sign_extended_type))
- {
- tree t = make_node (INTEGER_CST);
- TREE_INT_CST_LOW (t) = low;
- TREE_INT_CST_HIGH (t) = high;
- TREE_TYPE (t) = type;
- TREE_OVERFLOW (t) = 1;
- return t;
- }
- }
-
- /* Else build a shared node. */
- return build_int_cst_wide (type, low, high);
-}
-
/* Add two doubleword integers with doubleword result.
Return nonzero if the operation overflows according to UNSIGNED_P.
Each argument is given as two `HOST_WIDE_INT' pieces.
diff --git a/gcc/double-int.h b/gcc/double-int.h
index 250951d57f9..6af0757990c 100644
--- a/gcc/double-int.h
+++ b/gcc/double-int.h
@@ -269,8 +269,6 @@ double_int_equal_p (double_int cst1, double_int cst2)
/* Legacy interface with decomposed high/low parts. */
-extern tree force_fit_type_double (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT,
- int, bool);
extern int fit_double_type (unsigned HOST_WIDE_INT, HOST_WIDE_INT,
unsigned HOST_WIDE_INT *, HOST_WIDE_INT *,
const_tree);
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 7e7c0a20251..e2b30f90e8d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -27,8 +27,7 @@ along with GCC; see the file COPYING3. If not see
@@ This would also make life easier when this technology is used
@@ for cross-compilers. */
-/* The entry points in this file are fold, size_int_wide, size_binop
- and force_fit_type_double.
+/* The entry points in this file are fold, size_int_wide and size_binop.
fold takes a tree as argument and returns a simplified tree.
@@ -39,10 +38,6 @@ along with GCC; see the file COPYING3. If not see
size_int takes an integer value, and creates a tree constant
with type from `sizetype'.
- force_fit_type_double takes a constant, an overflowable flag and a
- prior overflow indicator. It forces the value to fit the type and
- sets TREE_OVERFLOW.
-
Note: Since the folders get called on non-gimple code as well as
gimple code, we need to handle GIMPLE tuples as well as their
corresponding tree equivalents. */
@@ -141,7 +136,7 @@ static tree fold_inf_compare (location_t, enum tree_code, tree, tree, tree);
static tree fold_div_compare (location_t, enum tree_code, tree, tree, tree);
static bool reorder_operands_p (const_tree, const_tree);
static tree fold_negate_const (tree, tree);
-static tree fold_not_const (tree, tree);
+static tree fold_not_const (const_tree, tree);
static tree fold_relational_const (enum tree_code, tree, tree, tree);
static tree fold_convert_const (enum tree_code, tree, tree);
@@ -1077,7 +1072,7 @@ int_const_binop (enum tree_code code, const_tree arg1, const_tree arg2, int notr
}
}
else
- t = force_fit_type_double (TREE_TYPE (arg1), res.low, res.high, 1,
+ t = force_fit_type_double (TREE_TYPE (arg1), res, 1,
((!uns || is_sizetype) && overflow)
| TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2));
@@ -1510,8 +1505,7 @@ fold_convert_const_int_from_int (tree type, const_tree arg1)
/* Given an integer constant, make new constant with new type,
appropriately sign-extended or truncated. */
- t = force_fit_type_double (type, TREE_INT_CST_LOW (arg1),
- TREE_INT_CST_HIGH (arg1),
+ t = force_fit_type_double (type, tree_to_double_int (arg1),
!POINTER_TYPE_P (TREE_TYPE (arg1)),
(TREE_INT_CST_HIGH (arg1) < 0
&& (TYPE_UNSIGNED (type)
@@ -1591,8 +1585,7 @@ fold_convert_const_int_from_real (enum tree_code code, tree type, const_tree arg
if (! overflow)
real_to_integer2 ((HOST_WIDE_INT *) &val.low, &val.high, &r);
- t = force_fit_type_double (type, val.low, val.high, -1,
- overflow | TREE_OVERFLOW (arg1));
+ t = force_fit_type_double (type, val, -1, overflow | TREE_OVERFLOW (arg1));
return t;
}
@@ -1635,7 +1628,7 @@ fold_convert_const_int_from_fixed (tree type, const_tree arg1)
/* Given a fixed-point constant, make new constant with new type,
appropriately sign-extended or truncated. */
- t = force_fit_type_double (type, temp.low, temp.high, -1,
+ t = force_fit_type_double (type, temp, -1,
(double_int_negative_p (temp)
&& (TYPE_UNSIGNED (type)
< TYPE_UNSIGNED (TREE_TYPE (arg1))))
@@ -5947,8 +5940,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
&& 0 != (t1 = int_const_binop (MULT_EXPR,
fold_convert (ctype, op1),
fold_convert (ctype, c), 1))
- && 0 != (t1 = force_fit_type_double (ctype, TREE_INT_CST_LOW (t1),
- TREE_INT_CST_HIGH (t1),
+ && 0 != (t1 = force_fit_type_double (ctype, tree_to_double_int (t1),
(TYPE_UNSIGNED (ctype)
&& tcode != MULT_EXPR) ? -1 : 1,
TREE_OVERFLOW (t1)))
@@ -6352,8 +6344,7 @@ fold_div_compare (location_t loc,
tree prod, tmp, hi, lo;
tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01 = TREE_OPERAND (arg0, 1);
- unsigned HOST_WIDE_INT lpart;
- HOST_WIDE_INT hpart;
+ double_int val;
bool unsigned_p = TYPE_UNSIGNED (TREE_TYPE (arg0));
bool neg_overflow;
int overflow;
@@ -6364,9 +6355,8 @@ fold_div_compare (location_t loc,
TREE_INT_CST_HIGH (arg01),
TREE_INT_CST_LOW (arg1),
TREE_INT_CST_HIGH (arg1),
- &lpart, &hpart, unsigned_p);
- prod = force_fit_type_double (TREE_TYPE (arg00), lpart, hpart,
- -1, overflow);
+ &val.low, &val.high, unsigned_p);
+ prod = force_fit_type_double (TREE_TYPE (arg00), val, -1, overflow);
neg_overflow = false;
if (unsigned_p)
@@ -6380,8 +6370,8 @@ fold_div_compare (location_t loc,
TREE_INT_CST_HIGH (prod),
TREE_INT_CST_LOW (tmp),
TREE_INT_CST_HIGH (tmp),
- &lpart, &hpart, unsigned_p);
- hi = force_fit_type_double (TREE_TYPE (arg00), lpart, hpart,
+ &val.low, &val.high, unsigned_p);
+ hi = force_fit_type_double (TREE_TYPE (arg00), val,
-1, overflow | TREE_OVERFLOW (prod));
}
else if (tree_int_cst_sgn (arg01) >= 0)
@@ -6834,9 +6824,8 @@ fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type,
return NULL_TREE;
if (TREE_CODE (arg1) == INTEGER_CST)
- arg1 = force_fit_type_double (inner_type, TREE_INT_CST_LOW (arg1),
- TREE_INT_CST_HIGH (arg1), 0,
- TREE_OVERFLOW (arg1));
+ arg1 = force_fit_type_double (inner_type, tree_to_double_int (arg1),
+ 0, TREE_OVERFLOW (arg1));
else
arg1 = fold_convert_loc (loc, inner_type, arg1);
@@ -7941,9 +7930,8 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
}
if (change)
{
- tem = force_fit_type_double (type, TREE_INT_CST_LOW (and1),
- TREE_INT_CST_HIGH (and1), 0,
- TREE_OVERFLOW (and1));
+ tem = force_fit_type_double (type, tree_to_double_int (and1),
+ 0, TREE_OVERFLOW (and1));
return fold_build2_loc (loc, BIT_AND_EXPR, type,
fold_convert_loc (loc, type, and0), tem);
}
@@ -15139,12 +15127,10 @@ fold_negate_const (tree arg0, tree type)
{
case INTEGER_CST:
{
- unsigned HOST_WIDE_INT low;
- HOST_WIDE_INT high;
- int overflow = neg_double (TREE_INT_CST_LOW (arg0),
- TREE_INT_CST_HIGH (arg0),
- &low, &high);
- t = force_fit_type_double (type, low, high, 1,
+ double_int val = tree_to_double_int (arg0);
+ int overflow = neg_double (val.low, val.high, &val.low, &val.high);
+
+ t = force_fit_type_double (type, val, 1,
(overflow | TREE_OVERFLOW (arg0))
&& !TYPE_UNSIGNED (type));
break;
@@ -15187,25 +15173,26 @@ fold_abs_const (tree arg0, tree type)
switch (TREE_CODE (arg0))
{
case INTEGER_CST:
- /* If the value is unsigned, then the absolute value is
- the same as the ordinary value. */
- if (TYPE_UNSIGNED (type))
- t = arg0;
- /* Similarly, if the value is non-negative. */
- else if (INT_CST_LT (integer_minus_one_node, arg0))
- t = arg0;
- /* If the value is negative, then the absolute value is
- its negation. */
- else
- {
- unsigned HOST_WIDE_INT low;
- HOST_WIDE_INT high;
- int overflow = neg_double (TREE_INT_CST_LOW (arg0),
- TREE_INT_CST_HIGH (arg0),
- &low, &high);
- t = force_fit_type_double (type, low, high, -1,
- overflow | TREE_OVERFLOW (arg0));
- }
+ {
+ double_int val = tree_to_double_int (arg0);
+
+ /* If the value is unsigned or non-negative, then the absolute value
+ is the same as the ordinary value. */
+ if (TYPE_UNSIGNED (type)
+ || !double_int_negative_p (val))
+ t = arg0;
+
+ /* If the value is negative, then the absolute value is
+ its negation. */
+ else
+ {
+ int overflow;
+
+ overflow = neg_double (val.low, val.high, &val.low, &val.high);
+ t = force_fit_type_double (type, val, -1,
+ overflow | TREE_OVERFLOW (arg0));
+ }
+ }
break;
case REAL_CST:
@@ -15226,17 +15213,14 @@ fold_abs_const (tree arg0, tree type)
constant. TYPE is the type of the result. */
static tree
-fold_not_const (tree arg0, tree type)
+fold_not_const (const_tree arg0, tree type)
{
- tree t = NULL_TREE;
+ double_int val;
gcc_assert (TREE_CODE (arg0) == INTEGER_CST);
- t = force_fit_type_double (type, ~TREE_INT_CST_LOW (arg0),
- ~TREE_INT_CST_HIGH (arg0), 0,
- TREE_OVERFLOW (arg0));
-
- return t;
+ val = double_int_not (tree_to_double_int (arg0));
+ return force_fit_type_double (type, val, 0, TREE_OVERFLOW (arg0));
}
/* Given CODE, a relational operator, the target type, TYPE and two
@@ -15634,25 +15618,23 @@ round_up_loc (location_t loc, tree value, int divisor)
{
if (TREE_CODE (value) == INTEGER_CST)
{
- unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (value);
- unsigned HOST_WIDE_INT high;
+ double_int val = tree_to_double_int (value);
bool overflow_p;
- if ((low & (divisor - 1)) == 0)
+ if ((val.low & (divisor - 1)) == 0)
return value;
overflow_p = TREE_OVERFLOW (value);
- high = TREE_INT_CST_HIGH (value);
- low &= ~(divisor - 1);
- low += divisor;
- if (low == 0)
+ val.low &= ~(divisor - 1);
+ val.low += divisor;
+ if (val.low == 0)
{
- high++;
- if (high == 0)
+ val.high++;
+ if (val.high == 0)
overflow_p = true;
}
- return force_fit_type_double (TREE_TYPE (value), low, high,
+ return force_fit_type_double (TREE_TYPE (value), val,
-1, overflow_p);
}
else
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index efeb4747788..590fa74efc8 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1511,10 +1511,10 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
/* Make sure to not set TREE_OVERFLOW on the final type
conversion. We are willingly interpreting large positive
unsigned values as negative singed values here. */
- min = force_fit_type_double (TREE_TYPE (var), TREE_INT_CST_LOW (min),
- TREE_INT_CST_HIGH (min), 0, false);
- max = force_fit_type_double (TREE_TYPE (var), TREE_INT_CST_LOW (max),
- TREE_INT_CST_HIGH (max), 0, false);
+ min = force_fit_type_double (TREE_TYPE (var), tree_to_double_int (min),
+ 0, false);
+ max = force_fit_type_double (TREE_TYPE (var), tree_to_double_int (max),
+ 0, false);
/* We can transform a max, min range to an anti-range or
vice-versa. Use set_and_canonicalize_value_range which does
@@ -2787,11 +2787,11 @@ extract_range_from_unary_expr (value_range_t *vr, enum tree_code code,
{
tree new_min, new_max;
new_min = force_fit_type_double (outer_type,
- TREE_INT_CST_LOW (vr0.min),
- TREE_INT_CST_HIGH (vr0.min), 0, 0);
+ tree_to_double_int (vr0.min),
+ 0, false);
new_max = force_fit_type_double (outer_type,
- TREE_INT_CST_LOW (vr0.max),
- TREE_INT_CST_HIGH (vr0.max), 0, 0);
+ tree_to_double_int (vr0.max),
+ 0, false);
if (is_overflow_infinity (vr0.min))
new_min = negative_overflow_infinity (outer_type);
if (is_overflow_infinity (vr0.max))
diff --git a/gcc/tree.c b/gcc/tree.c
index 5e7de012e2a..de83e64cea1 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1092,6 +1092,52 @@ double_int_fits_to_tree_p (const_tree type, double_int cst)
return double_int_equal_p (cst, ext);
}
+/* We force the double_int CST to the range of the type TYPE by sign or
+ zero extending it. OVERFLOWABLE indicates if we are interested in
+ overflow of the value, when >0 we are only interested in signed
+ overflow, for <0 we are interested in any overflow. OVERFLOWED
+ indicates whether overflow has already occurred. CONST_OVERFLOWED
+ indicates whether constant overflow has already occurred. We force
+ T's value to be within range of T's type (by setting to 0 or 1 all
+ the bits outside the type's range). We set TREE_OVERFLOWED if,
+ OVERFLOWED is nonzero,
+ or OVERFLOWABLE is >0 and signed overflow occurs
+ or OVERFLOWABLE is <0 and any overflow occurs
+ We return a new tree node for the extended double_int. The node
+ is shared if no overflow flags are set. */
+
+
+tree
+force_fit_type_double (tree type, double_int cst, int overflowable,
+ bool overflowed)
+{
+ bool sign_extended_type;
+
+ /* Size types *are* sign extended. */
+ sign_extended_type = (!TYPE_UNSIGNED (type)
+ || (TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_IS_SIZETYPE (type)));
+
+ /* If we need to set overflow flags, return a new unshared node. */
+ if (overflowed || !double_int_fits_to_tree_p(type, cst))
+ {
+ if (overflowed
+ || overflowable < 0
+ || (overflowable > 0 && sign_extended_type))
+ {
+ tree t = make_node (INTEGER_CST);
+ TREE_INT_CST (t) = double_int_ext (cst, TYPE_PRECISION (type),
+ !sign_extended_type);
+ TREE_TYPE (t) = type;
+ TREE_OVERFLOW (t) = 1;
+ return t;
+ }
+ }
+
+ /* Else build a shared node. */
+ return double_int_to_tree (type, cst);
+}
+
/* These are the hash table functions for the hash table of INTEGER_CST
nodes of a sizetype. */
diff --git a/gcc/tree.h b/gcc/tree.h
index 967b4b27372..b3ba5493fd4 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4014,6 +4014,7 @@ tree_to_double_int (const_tree cst)
extern tree double_int_to_tree (tree, double_int);
extern bool double_int_fits_to_tree_p (const_tree, double_int);
+extern tree force_fit_type_double (tree, double_int, int, bool);
/* Create an INT_CST node with a CST value zero extended. */