Commit f457cf40 by James A. Morrison

fold-const.c (optimize_bit_field_compare): Remove extra fold call.

2005-08-16  James A. Morrison  <phython@gcc.gnu.org>

        * fold-const.c (optimize_bit_field_compare): Remove extra fold call.
        (try_move_mult_to_index): Call fold_build2 instead of build2.
        (fold_binary): Don't call fold after calls to try_move_mult_to_index.
        * tree-ssa-loop-niter.c (inverse): Call int_const_binop instead of
        fold_binary_to_constant.
        (infer_loop_bounds_from_undefined): Call fold_build2 instead of
        fold (build.
        * tree-data-ref.c (tree_fold_divides_p): Use tree_int_cst_equal to
        check if A == gcd (A, B).  Remove TYPE argument.
        (analyze_offset) Use fold_build2 instead of fold (build.
        (create_data_ref): Likewise.
        (analyze_siv_subscript_cst_affine): Update calls to tree_fold_divides_p.        * tree-ssa-ccp.c (widen_bitfield): Call fold_build2 instead of build2
        then fold.

From-SVN: r103200
parent 0cbe2a68
2005-08-16 James A. Morrison <phython@gcc.gnu.org>
* fold-const.c (optimize_bit_field_compare): Remove extra fold call.
(try_move_mult_to_index): Call fold_build2 instead of build2.
(fold_binary): Don't call fold after calls to try_move_mult_to_index.
* tree-ssa-loop-niter.c (inverse): Call int_const_binop instead of
fold_binary_to_constant.
(infer_loop_bounds_from_undefined): Call fold_build2 instead of
fold (build.
* tree-data-ref.c (tree_fold_divides_p): Use tree_int_cst_equal to
check if A == gcd (A, B). Remove TYPE argument.
(analyze_offset) Use fold_build2 instead of fold (build.
(create_data_ref): Likewise.
(analyze_siv_subscript_cst_affine): Update calls to tree_fold_divides_p.
* tree-ssa-ccp.c (widen_bitfield): Call fold_build2 instead of build2
then fold.
2005-08-17 Kelley Cook <kcook@gcc.gnu.org> 2005-08-17 Kelley Cook <kcook@gcc.gnu.org>
* config/arm/unaligned-funcs.c,config/i386/crtfastmath.c, * config/arm/unaligned-funcs.c,config/i386/crtfastmath.c,
......
...@@ -3340,11 +3340,11 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, ...@@ -3340,11 +3340,11 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type,
TREE_THIS_VOLATILE (lhs) = 1; TREE_THIS_VOLATILE (lhs) = 1;
} }
rhs = fold (const_binop (BIT_AND_EXPR, rhs = const_binop (BIT_AND_EXPR,
const_binop (LSHIFT_EXPR, const_binop (LSHIFT_EXPR,
fold_convert (unsigned_type, rhs), fold_convert (unsigned_type, rhs),
size_int (lbitpos), 0), size_int (lbitpos), 0),
mask, 0)); mask, 0);
return build2 (code, compare_type, return build2 (code, compare_type,
build2 (BIT_AND_EXPR, unsigned_type, lhs, mask), build2 (BIT_AND_EXPR, unsigned_type, lhs, mask),
...@@ -6468,7 +6468,7 @@ try_move_mult_to_index (enum tree_code code, tree addr, tree op1) ...@@ -6468,7 +6468,7 @@ try_move_mult_to_index (enum tree_code code, tree addr, tree op1)
TREE_OPERAND (pos, 1)), TREE_OPERAND (pos, 1)),
fold_convert (itype, delta)); fold_convert (itype, delta));
return build1 (ADDR_EXPR, TREE_TYPE (addr), ret); return fold_build1 (ADDR_EXPR, TREE_TYPE (addr), ret);
} }
...@@ -7305,13 +7305,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ...@@ -7305,13 +7305,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
{ {
tem = try_move_mult_to_index (PLUS_EXPR, arg0, arg1); tem = try_move_mult_to_index (PLUS_EXPR, arg0, arg1);
if (tem) if (tem)
return fold_convert (type, fold (tem)); return fold_convert (type, tem);
} }
else if (TREE_CODE (arg1) == ADDR_EXPR) else if (TREE_CODE (arg1) == ADDR_EXPR)
{ {
tem = try_move_mult_to_index (PLUS_EXPR, arg1, arg0); tem = try_move_mult_to_index (PLUS_EXPR, arg1, arg0);
if (tem) if (tem)
return fold_convert (type, fold (tem)); return fold_convert (type, tem);
} }
} }
else else
...@@ -7730,7 +7730,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ...@@ -7730,7 +7730,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
{ {
tem = try_move_mult_to_index (MINUS_EXPR, arg0, arg1); tem = try_move_mult_to_index (MINUS_EXPR, arg0, arg1);
if (tem) if (tem)
return fold_convert (type, fold (tem)); return fold_convert (type, tem);
} }
if (flag_unsafe_math_optimizations if (flag_unsafe_math_optimizations
......
...@@ -479,13 +479,11 @@ base_addr_differ_p (struct data_reference *dra, ...@@ -479,13 +479,11 @@ base_addr_differ_p (struct data_reference *dra,
/* Returns true iff A divides B. */ /* Returns true iff A divides B. */
static inline bool static inline bool
tree_fold_divides_p (tree type, tree_fold_divides_p (tree a,
tree a,
tree b) tree b)
{ {
/* Determines whether (A == gcd (A, B)). */ /* Determines whether (A == gcd (A, B)). */
return integer_zerop return tree_int_cst_equal (a, tree_fold_gcd (a, b));
(fold_build2 (MINUS_EXPR, type, a, tree_fold_gcd (a, b)));
} }
/* Compute the greatest common denominator of two numbers using /* Compute the greatest common denominator of two numbers using
...@@ -1723,7 +1721,7 @@ analyze_offset (tree offset, tree *invariant, tree *constant) ...@@ -1723,7 +1721,7 @@ analyze_offset (tree offset, tree *invariant, tree *constant)
*constant = constant_0 ? constant_0 : constant_1; *constant = constant_0 ? constant_0 : constant_1;
if (invariant_0 && invariant_1) if (invariant_0 && invariant_1)
*invariant = *invariant =
fold (build (code, TREE_TYPE (invariant_0), invariant_0, invariant_1)); fold_build2 (code, TREE_TYPE (invariant_0), invariant_0, invariant_1);
else else
*invariant = invariant_0 ? invariant_0 : invariant_1; *invariant = invariant_0 ? invariant_0 : invariant_1;
} }
...@@ -1805,8 +1803,8 @@ create_data_ref (tree memref, tree stmt, bool is_read) ...@@ -1805,8 +1803,8 @@ create_data_ref (tree memref, tree stmt, bool is_read)
if (constant) if (constant)
{ {
DR_INIT (dr) = fold_convert (ssizetype, constant); DR_INIT (dr) = fold_convert (ssizetype, constant);
init_cond = fold (build (TRUNC_DIV_EXPR, TREE_TYPE (constant), init_cond = fold_build2 (TRUNC_DIV_EXPR, TREE_TYPE (constant),
constant, type_size)); constant, type_size);
} }
else else
DR_INIT (dr) = init_cond = ssize_int (0);; DR_INIT (dr) = init_cond = ssize_int (0);;
...@@ -2186,8 +2184,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a, ...@@ -2186,8 +2184,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
chrec_b = {10, +, 1} chrec_b = {10, +, 1}
*/ */
if (tree_fold_divides_p if (tree_fold_divides_p (CHREC_RIGHT (chrec_b), difference))
(integer_type_node, CHREC_RIGHT (chrec_b), difference))
{ {
*overlaps_a = integer_zero_node; *overlaps_a = integer_zero_node;
*overlaps_b = fold_build2 (EXACT_DIV_EXPR, integer_type_node, *overlaps_b = fold_build2 (EXACT_DIV_EXPR, integer_type_node,
...@@ -2199,7 +2196,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a, ...@@ -2199,7 +2196,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
return; return;
} }
/* When the step does not divides the difference, there are /* When the step does not divide the difference, there are
no overlaps. */ no overlaps. */
else else
{ {
...@@ -2241,13 +2238,12 @@ analyze_siv_subscript_cst_affine (tree chrec_a, ...@@ -2241,13 +2238,12 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
chrec_a = 3 chrec_a = 3
chrec_b = {10, +, -1} chrec_b = {10, +, -1}
*/ */
if (tree_fold_divides_p if (tree_fold_divides_p (CHREC_RIGHT (chrec_b), difference))
(integer_type_node, CHREC_RIGHT (chrec_b), difference))
{ {
*overlaps_a = integer_zero_node; *overlaps_a = integer_zero_node;
*overlaps_b = fold *overlaps_b = fold_build2 (EXACT_DIV_EXPR,
(build (EXACT_DIV_EXPR, integer_type_node, difference, integer_type_node, difference,
CHREC_RIGHT (chrec_b))); CHREC_RIGHT (chrec_b));
*last_conflicts = integer_one_node; *last_conflicts = integer_one_node;
return; return;
} }
...@@ -2816,7 +2812,7 @@ chrec_steps_divide_constant_p (tree chrec, ...@@ -2816,7 +2812,7 @@ chrec_steps_divide_constant_p (tree chrec,
switch (TREE_CODE (chrec)) switch (TREE_CODE (chrec))
{ {
case POLYNOMIAL_CHREC: case POLYNOMIAL_CHREC:
return (tree_fold_divides_p (integer_type_node, CHREC_RIGHT (chrec), cst) return (tree_fold_divides_p (CHREC_RIGHT (chrec), cst)
&& chrec_steps_divide_constant_p (CHREC_LEFT (chrec), cst)); && chrec_steps_divide_constant_p (CHREC_LEFT (chrec), cst));
default: default:
......
...@@ -1432,8 +1432,8 @@ widen_bitfield (tree val, tree field, tree var) ...@@ -1432,8 +1432,8 @@ widen_bitfield (tree val, tree field, tree var)
for (i = 0, mask = 0; i < field_size; i++) for (i = 0, mask = 0; i < field_size; i++)
mask |= ((HOST_WIDE_INT) 1) << i; mask |= ((HOST_WIDE_INT) 1) << i;
wide_val = build2 (BIT_AND_EXPR, TREE_TYPE (var), val, wide_val = fold_build2 (BIT_AND_EXPR, TREE_TYPE (var), val,
build_int_cst (TREE_TYPE (var), mask)); build_int_cst (TREE_TYPE (var), mask));
} }
else else
{ {
...@@ -1443,11 +1443,11 @@ widen_bitfield (tree val, tree field, tree var) ...@@ -1443,11 +1443,11 @@ widen_bitfield (tree val, tree field, tree var)
for (i = 0, mask = 0; i < (var_size - field_size); i++) for (i = 0, mask = 0; i < (var_size - field_size); i++)
mask |= ((HOST_WIDE_INT) 1) << (var_size - i - 1); mask |= ((HOST_WIDE_INT) 1) << (var_size - i - 1);
wide_val = build2 (BIT_IOR_EXPR, TREE_TYPE (var), val, wide_val = fold_build2 (BIT_IOR_EXPR, TREE_TYPE (var), val,
build_int_cst (TREE_TYPE (var), mask)); build_int_cst (TREE_TYPE (var), mask));
} }
return fold (wide_val); return wide_val;
} }
......
...@@ -117,10 +117,10 @@ inverse (tree x, tree mask) ...@@ -117,10 +117,10 @@ inverse (tree x, tree mask)
rslt = build_int_cst_type (type, 1); rslt = build_int_cst_type (type, 1);
for (; ctr; ctr--) for (; ctr; ctr--)
{ {
rslt = fold_binary_to_constant (MULT_EXPR, type, rslt, x); rslt = int_const_binop (MULT_EXPR, rslt, x, 0);
x = fold_binary_to_constant (MULT_EXPR, type, x, x); x = int_const_binop (MULT_EXPR, x, x, 0);
} }
rslt = fold_binary_to_constant (BIT_AND_EXPR, type, rslt, mask); rslt = int_const_binop (BIT_AND_EXPR, rslt, mask, 0);
} }
return rslt; return rslt;
...@@ -1465,14 +1465,14 @@ infer_loop_bounds_from_undefined (struct loop *loop) ...@@ -1465,14 +1465,14 @@ infer_loop_bounds_from_undefined (struct loop *loop)
utype = unsigned_type_for (type); utype = unsigned_type_for (type);
if (tree_int_cst_lt (step, integer_zero_node)) if (tree_int_cst_lt (step, integer_zero_node))
diff = fold (build2 (MINUS_EXPR, utype, init, diff = fold_build2 (MINUS_EXPR, utype, init,
TYPE_MIN_VALUE (type))); TYPE_MIN_VALUE (type));
else else
diff = fold (build2 (MINUS_EXPR, utype, diff = fold_build2 (MINUS_EXPR, utype,
TYPE_MAX_VALUE (type), init)); TYPE_MAX_VALUE (type), init);
estimation = fold (build2 (CEIL_DIV_EXPR, utype, diff, estimation = fold_build2 (CEIL_DIV_EXPR, utype, diff,
step)); step);
record_estimate (loop, estimation, boolean_true_node, stmt); record_estimate (loop, estimation, boolean_true_node, stmt);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment