aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2007-01-11 16:03:10 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2007-01-11 16:03:10 +0000
commit455f14dd4d6e0210975f5cd5e4757674cca015ce (patch)
tree5157a9420ebb815f559803d5e9c4eaba6cd46d9b /gcc/fold-const.c
parent95fd24b6415774f9517b4b5c5d989e535e54e724 (diff)
downloadgcc-455f14dd4d6e0210975f5cd5e4757674cca015ce.zip
gcc-455f14dd4d6e0210975f5cd5e4757674cca015ce.tar.gz
gcc-455f14dd4d6e0210975f5cd5e4757674cca015ce.tar.bz2
builtins.c (expand_builtin_pow, [...]): Replace uses of the macro TREE_CONSTANT_OVERFLOW with TREE_OVERFLOW.
* builtins.c (expand_builtin_pow, expand_builtin_powi, fold_builtin_cabs, fold_builtin_sqrt, fold_builtin_trunc, fold_builtin_floor, fold_builtin_ceil, fold_builtin_round, fold_builtin_int_int_roundingfn, fold_builtin_bitop, fold_builtin_bswap, real_constp, fold_builtin_pow, fold_builtin_powi, fold_builtin_signbit, fold_builtin_copysign, do_mpfr_arg1, do_mpfr_arg2, do_mpfr_arg3, do_mpfr_sincos): Replace uses of the macro TREE_CONSTANT_OVERFLOW with TREE_OVERFLOW. * convert.c (convert_to_pointer): Likewise. * expr.c (highest_pow2_factor, expand_expr_real_1): Likewise. * fold-const.c (force_fit_type, fold_negate_expr, int_const_binop, const_binop, fold_convert_const_int_from_int, fold_convert_const_int_from_real, fold_convert_const_real_from_real, sign_bit_p, optimize_minmax_comparison, extract_muldiv_1, fold_div_compare, fold_sign_changed_comparison, fold_unary, fold_comparison, fold_binary, multiple_of_p, tree_Expr_non_zero_p, fold_negate_const, fold_abs_const, fold_not_const): Likewise. * print-tree.c (print_node_brief, print_node): Likewise. * stor-layout.c (place_field, layout_type): Likewise. * tree-chrec.c (keep_cast): Likewise. * tree.c (build_vector, build_real, build_real_from_int_cst, build_complex): Likewise. From-SVN: r120678
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c101
1 files changed, 35 insertions, 66 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9f116b5..3a3fe36 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -41,7 +41,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
force_fit_type takes a constant, an overflowable flag and prior
overflow indicators. It forces the value to fit the type and sets
- TREE_OVERFLOW and TREE_CONSTANT_OVERFLOW as appropriate.
+ TREE_OVERFLOW as appropriate.
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
@@ -275,9 +275,6 @@ fit_double_type (unsigned HOST_WIDE_INT l1, HOST_WIDE_INT h1,
OVERFLOWED is nonzero,
or OVERFLOWABLE is >0 and signed overflow occurs
or OVERFLOWABLE is <0 and any overflow occurs
- We set TREE_CONSTANT_OVERFLOWED if,
- CONST_OVERFLOWED is nonzero
- or we set TREE_OVERFLOWED.
We return a new tree node for the extended double-int. The node
is shared if no overflow flags are set. */
@@ -308,18 +305,6 @@ force_fit_type_double (tree type, unsigned HOST_WIDE_INT low,
TREE_INT_CST_HIGH (t) = high;
TREE_TYPE (t) = type;
TREE_OVERFLOW (t) = 1;
- TREE_CONSTANT_OVERFLOW (t) = 1;
-
- return t;
- }
- else if (overflowed_const)
- {
- tree t = make_node (INTEGER_CST);
- TREE_INT_CST_LOW (t) = low;
- TREE_INT_CST_HIGH (t) = high;
- TREE_TYPE (t) = type;
- TREE_CONSTANT_OVERFLOW (t) = 1;
-
return t;
}
}
@@ -1115,16 +1100,16 @@ fold_negate_expr (tree t)
case INTEGER_CST:
tem = fold_negate_const (t, type);
- if (! TREE_OVERFLOW (tem)
+ if (!TREE_OVERFLOW (tem)
|| TYPE_UNSIGNED (type)
- || ! flag_trapv)
+ || !flag_trapv)
return tem;
break;
case REAL_CST:
tem = fold_negate_const (t, type);
/* Two's complement FP formats, such as c4x, may overflow. */
- if (! TREE_OVERFLOW (tem) || ! flag_trapping_math)
+ if (!TREE_OVERFLOW (tem) || !flag_trapping_math)
return tem;
break;
@@ -1530,8 +1515,8 @@ int_const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
case EXACT_DIV_EXPR:
/* This is a shortcut for a common special case. */
if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
- && ! TREE_CONSTANT_OVERFLOW (arg1)
- && ! TREE_CONSTANT_OVERFLOW (arg2)
+ && !TREE_OVERFLOW (arg1)
+ && !TREE_OVERFLOW (arg2)
&& int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
{
if (code == CEIL_DIV_EXPR)
@@ -1565,8 +1550,8 @@ int_const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
case FLOOR_MOD_EXPR: case CEIL_MOD_EXPR:
/* This is a shortcut for a common special case. */
if (int2h == 0 && (HOST_WIDE_INT) int2l > 0
- && ! TREE_CONSTANT_OVERFLOW (arg1)
- && ! TREE_CONSTANT_OVERFLOW (arg2)
+ && !TREE_OVERFLOW (arg1)
+ && !TREE_OVERFLOW (arg2)
&& int1h == 0 && (HOST_WIDE_INT) int1l >= 0)
{
if (code == CEIL_MOD_EXPR)
@@ -1617,20 +1602,13 @@ int_const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
{
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));
+ false);
return t;
}
@@ -1731,10 +1709,6 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
t = build_real (type, result);
TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2);
- TREE_CONSTANT_OVERFLOW (t)
- = TREE_OVERFLOW (t)
- | TREE_CONSTANT_OVERFLOW (arg1)
- | TREE_CONSTANT_OVERFLOW (arg2);
return t;
}
@@ -1911,7 +1885,7 @@ fold_convert_const_int_from_int (tree type, tree arg1)
&& (TYPE_UNSIGNED (type)
< TYPE_UNSIGNED (TREE_TYPE (arg1))))
| TREE_OVERFLOW (arg1),
- TREE_CONSTANT_OVERFLOW (arg1));
+ false);
return t;
}
@@ -1991,7 +1965,7 @@ fold_convert_const_int_from_real (enum tree_code code, tree type, tree arg1)
t = force_fit_type_double (type, low, high, -1,
overflow | TREE_OVERFLOW (arg1),
- TREE_CONSTANT_OVERFLOW (arg1));
+ false);
return t;
}
@@ -2008,8 +1982,6 @@ fold_convert_const_real_from_real (tree type, tree arg1)
t = build_real (type, value);
TREE_OVERFLOW (t) = TREE_OVERFLOW (arg1);
- TREE_CONSTANT_OVERFLOW (t)
- = TREE_OVERFLOW (t) | TREE_CONSTANT_OVERFLOW (arg1);
return t;
}
@@ -3696,7 +3668,7 @@ sign_bit_p (tree exp, tree val)
/* Tree VAL must be an integer constant. */
if (TREE_CODE (val) != INTEGER_CST
- || TREE_CONSTANT_OVERFLOW (val))
+ || TREE_OVERFLOW (val))
return NULL_TREE;
width = TYPE_PRECISION (t);
@@ -5347,9 +5319,9 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1)
/* If something does not permit us to optimize, return the original tree. */
if ((op_code != MIN_EXPR && op_code != MAX_EXPR)
|| TREE_CODE (comp_const) != INTEGER_CST
- || TREE_CONSTANT_OVERFLOW (comp_const)
+ || TREE_OVERFLOW (comp_const)
|| TREE_CODE (minmax_const) != INTEGER_CST
- || TREE_CONSTANT_OVERFLOW (minmax_const))
+ || TREE_OVERFLOW (minmax_const))
return NULL_TREE;
/* Now handle all the various comparison codes. We only handle EQ_EXPR
@@ -5526,7 +5498,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type)
possible later conversion to our or some other type. */
if ((t2 = fold_convert (TREE_TYPE (op0), c)) != 0
&& TREE_CODE (t2) == INTEGER_CST
- && ! TREE_CONSTANT_OVERFLOW (t2)
+ && !TREE_OVERFLOW (t2)
&& (0 != (t1 = extract_muldiv (op0, t2, code,
code == MULT_EXPR
? ctype : NULL_TREE))))
@@ -5587,7 +5559,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type)
const_binop (LSHIFT_EXPR,
size_one_node,
op1, 0)))
- && ! TREE_OVERFLOW (t1))
+ && !TREE_OVERFLOW (t1))
return extract_muldiv (build2 (tcode == LSHIFT_EXPR
? MULT_EXPR : FLOOR_DIV_EXPR,
ctype, fold_convert (ctype, op0), t1),
@@ -5704,7 +5676,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type)
if (tcode == code
&& 0 != (t1 = const_binop (MULT_EXPR, fold_convert (ctype, op1),
fold_convert (ctype, c), 0))
- && ! TREE_OVERFLOW (t1))
+ && !TREE_OVERFLOW (t1))
return fold_build2 (tcode, ctype, fold_convert (ctype, op0), t1);
/* If these operations "cancel" each other, we have the main
@@ -6188,7 +6160,7 @@ fold_div_compare (enum tree_code code, tree type, tree arg0, tree arg1)
&lpart, &hpart, unsigned_p);
hi = force_fit_type_double (TREE_TYPE (arg00), lpart, hpart,
-1, overflow | TREE_OVERFLOW (prod),
- TREE_CONSTANT_OVERFLOW (prod));
+ false);
}
else if (tree_int_cst_sgn (arg01) >= 0)
{
@@ -6625,7 +6597,7 @@ fold_sign_changed_comparison (enum tree_code code, tree type,
arg1 = force_fit_type_double (inner_type, TREE_INT_CST_LOW (arg1),
TREE_INT_CST_HIGH (arg1), 0,
TREE_OVERFLOW (arg1),
- TREE_CONSTANT_OVERFLOW (arg1));
+ false);
else
arg1 = fold_convert (inner_type, arg1);
@@ -7560,7 +7532,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
tem = force_fit_type_double (type, TREE_INT_CST_LOW (and1),
TREE_INT_CST_HIGH (and1), 0,
TREE_OVERFLOW (and1),
- TREE_CONSTANT_OVERFLOW (and1));
+ false);
return fold_build2 (BIT_AND_EXPR, type,
fold_convert (type, and0), tem);
}
@@ -8285,7 +8257,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
&& 0 != (tem = const_binop (TREE_CODE (arg0) == PLUS_EXPR
? MINUS_EXPR : PLUS_EXPR,
arg1, TREE_OPERAND (arg0, 1), 0))
- && ! TREE_CONSTANT_OVERFLOW (tem))
+ && !TREE_OVERFLOW (tem))
return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
/* Likewise, we can simplify a comparison of a real constant with
@@ -8297,7 +8269,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
&& TREE_CODE (TREE_OPERAND (arg0, 0)) == REAL_CST
&& 0 != (tem = const_binop (MINUS_EXPR, TREE_OPERAND (arg0, 0),
arg1, 0))
- && ! TREE_CONSTANT_OVERFLOW (tem))
+ && !TREE_OVERFLOW (tem))
return fold_build2 (swap_tree_comparison (code), type,
TREE_OPERAND (arg0, 1), tem);
@@ -9541,7 +9513,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
tree arg11 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg1,
1)));
if (TREE_CODE (arg11) == REAL_CST
- && ! TREE_CONSTANT_OVERFLOW (arg11)
+ && !TREE_OVERFLOW (arg11)
&& operand_equal_p (arg0, arg10, 0))
{
tree powfn = TREE_OPERAND (TREE_OPERAND (arg1, 0), 0);
@@ -9566,7 +9538,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0,
1)));
if (TREE_CODE (arg01) == REAL_CST
- && ! TREE_CONSTANT_OVERFLOW (arg01)
+ && !TREE_OVERFLOW (arg01)
&& operand_equal_p (arg1, arg00, 0))
{
tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
@@ -10208,7 +10180,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
tree arg00 = TREE_VALUE (TREE_OPERAND (arg0, 1));
tree arg01 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (arg0, 1)));
if (TREE_CODE (arg01) == REAL_CST
- && ! TREE_CONSTANT_OVERFLOW (arg01)
+ && !TREE_OVERFLOW (arg01)
&& operand_equal_p (arg1, arg00, 0))
{
tree powfn = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0);
@@ -10367,7 +10339,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (code == TRUNC_MOD_EXPR
&& !TYPE_UNSIGNED (type)
&& TREE_CODE (arg1) == INTEGER_CST
- && !TREE_CONSTANT_OVERFLOW (arg1)
+ && !TREE_OVERFLOW (arg1)
&& TREE_INT_CST_HIGH (arg1) < 0
&& !flag_trapv
/* Avoid this transformation if C is INT_MIN, i.e. C == -C. */
@@ -10781,7 +10753,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
? MINUS_EXPR : PLUS_EXPR,
fold_convert (TREE_TYPE (arg0), arg1),
TREE_OPERAND (arg0, 1), 0))
- && ! TREE_CONSTANT_OVERFLOW (tem))
+ && !TREE_OVERFLOW (tem))
return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
/* Similarly for a NEGATE_EXPR. */
@@ -10789,7 +10761,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& TREE_CODE (arg1) == INTEGER_CST
&& 0 != (tem = negate_expr (arg1))
&& TREE_CODE (tem) == INTEGER_CST
- && ! TREE_CONSTANT_OVERFLOW (tem))
+ && !TREE_OVERFLOW (tem))
return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
/* Similarly for a BIT_XOR_EXPR; X ^ C1 == C2 is X == (C1 ^ C2). */
@@ -11293,7 +11265,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
unsigned int width = TYPE_PRECISION (arg1_type);
if (TREE_CODE (arg1) == INTEGER_CST
- && ! TREE_CONSTANT_OVERFLOW (arg1)
+ && !TREE_OVERFLOW (arg1)
&& width <= 2 * HOST_BITS_PER_WIDE_INT
&& (INTEGRAL_TYPE_P (arg1_type) || POINTER_TYPE_P (arg1_type)))
{
@@ -11452,7 +11424,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
&& ! TREE_SIDE_EFFECTS (arg0)
&& (0 != (tem = negate_expr (arg1)))
&& TREE_CODE (tem) == INTEGER_CST
- && ! TREE_CONSTANT_OVERFLOW (tem))
+ && !TREE_OVERFLOW (tem))
return fold_build2 (TRUTH_ANDIF_EXPR, type,
build2 (GE_EXPR, type,
TREE_OPERAND (arg0, 0), tem),
@@ -12516,7 +12488,7 @@ multiple_of_p (tree type, tree top, tree bottom)
const_binop (LSHIFT_EXPR,
size_one_node,
op1, 0)))
- && ! TREE_OVERFLOW (t1))
+ && !TREE_OVERFLOW (t1))
return multiple_of_p (type, t1, bottom);
}
return 0;
@@ -12872,10 +12844,7 @@ tree_expr_nonzero_p (tree t)
return tree_expr_nonzero_p (TREE_OPERAND (t, 0));
case INTEGER_CST:
- /* We used to test for !integer_zerop here. This does not work correctly
- if TREE_CONSTANT_OVERFLOW (t). */
- return (TREE_INT_CST_LOW (t) != 0
- || TREE_INT_CST_HIGH (t) != 0);
+ return !integer_zerop (t);
case PLUS_EXPR:
if (!TYPE_UNSIGNED (type) && !flag_wrapv)
@@ -13077,7 +13046,7 @@ fold_negate_const (tree arg0, tree type)
t = force_fit_type_double (type, low, high, 1,
(overflow | TREE_OVERFLOW (arg0))
&& !TYPE_UNSIGNED (type),
- TREE_CONSTANT_OVERFLOW (arg0));
+ false);
break;
}
@@ -13123,7 +13092,7 @@ fold_abs_const (tree arg0, tree type)
&low, &high);
t = force_fit_type_double (type, low, high, -1,
overflow | TREE_OVERFLOW (arg0),
- TREE_CONSTANT_OVERFLOW (arg0));
+ false);
}
break;
@@ -13154,7 +13123,7 @@ fold_not_const (tree arg0, tree type)
t = force_fit_type_double (type, ~TREE_INT_CST_LOW (arg0),
~TREE_INT_CST_HIGH (arg0), 0,
TREE_OVERFLOW (arg0),
- TREE_CONSTANT_OVERFLOW (arg0));
+ false);
return t;
}