aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJames A. Morrison <phython@gcc.gnu.org>2005-08-17 03:56:20 +0000
committerJames A. Morrison <phython@gcc.gnu.org>2005-08-17 03:56:20 +0000
commit8a4363e97f265eafdeee3b2139c0d485f1a9c797 (patch)
treebf56b200973247a5d5406c02f3422ef6f6a55621 /gcc
parentf9987a087c99cf00b8a5d8f617c7b1929f9aeb08 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@103200 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/fold-const.c18
-rw-r--r--gcc/tree-data-ref.c28
-rw-r--r--gcc/tree-ssa-ccp.c10
-rw-r--r--gcc/tree-ssa-loop-niter.c18
5 files changed, 52 insertions, 39 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e60051d01c5..ebd71a1f53d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+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>
* config/arm/unaligned-funcs.c,config/i386/crtfastmath.c,
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index db82baae00c..6853b413f09 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3340,11 +3340,11 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type,
TREE_THIS_VOLATILE (lhs) = 1;
}
- rhs = fold (const_binop (BIT_AND_EXPR,
- const_binop (LSHIFT_EXPR,
- fold_convert (unsigned_type, rhs),
- size_int (lbitpos), 0),
- mask, 0));
+ rhs = const_binop (BIT_AND_EXPR,
+ const_binop (LSHIFT_EXPR,
+ fold_convert (unsigned_type, rhs),
+ size_int (lbitpos), 0),
+ mask, 0);
return build2 (code, compare_type,
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)
TREE_OPERAND (pos, 1)),
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)
{
tem = try_move_mult_to_index (PLUS_EXPR, arg0, arg1);
if (tem)
- return fold_convert (type, fold (tem));
+ return fold_convert (type, tem);
}
else if (TREE_CODE (arg1) == ADDR_EXPR)
{
tem = try_move_mult_to_index (PLUS_EXPR, arg1, arg0);
if (tem)
- return fold_convert (type, fold (tem));
+ return fold_convert (type, tem);
}
}
else
@@ -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);
if (tem)
- return fold_convert (type, fold (tem));
+ return fold_convert (type, tem);
}
if (flag_unsafe_math_optimizations
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 1848128551a..568de38deb4 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -479,13 +479,11 @@ base_addr_differ_p (struct data_reference *dra,
/* Returns true iff A divides B. */
static inline bool
-tree_fold_divides_p (tree type,
- tree a,
+tree_fold_divides_p (tree a,
tree b)
{
/* Determines whether (A == gcd (A, B)). */
- return integer_zerop
- (fold_build2 (MINUS_EXPR, type, a, tree_fold_gcd (a, b)));
+ return tree_int_cst_equal (a, tree_fold_gcd (a, b));
}
/* Compute the greatest common denominator of two numbers using
@@ -1723,7 +1721,7 @@ analyze_offset (tree offset, tree *invariant, tree *constant)
*constant = constant_0 ? constant_0 : constant_1;
if (invariant_0 && invariant_1)
*invariant =
- fold (build (code, TREE_TYPE (invariant_0), invariant_0, invariant_1));
+ fold_build2 (code, TREE_TYPE (invariant_0), invariant_0, invariant_1);
else
*invariant = invariant_0 ? invariant_0 : invariant_1;
}
@@ -1805,8 +1803,8 @@ create_data_ref (tree memref, tree stmt, bool is_read)
if (constant)
{
DR_INIT (dr) = fold_convert (ssizetype, constant);
- init_cond = fold (build (TRUNC_DIV_EXPR, TREE_TYPE (constant),
- constant, type_size));
+ init_cond = fold_build2 (TRUNC_DIV_EXPR, TREE_TYPE (constant),
+ constant, type_size);
}
else
DR_INIT (dr) = init_cond = ssize_int (0);;
@@ -2186,8 +2184,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
chrec_b = {10, +, 1}
*/
- if (tree_fold_divides_p
- (integer_type_node, CHREC_RIGHT (chrec_b), difference))
+ if (tree_fold_divides_p (CHREC_RIGHT (chrec_b), difference))
{
*overlaps_a = integer_zero_node;
*overlaps_b = fold_build2 (EXACT_DIV_EXPR, integer_type_node,
@@ -2199,7 +2196,7 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
return;
}
- /* When the step does not divides the difference, there are
+ /* When the step does not divide the difference, there are
no overlaps. */
else
{
@@ -2241,13 +2238,12 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
chrec_a = 3
chrec_b = {10, +, -1}
*/
- if (tree_fold_divides_p
- (integer_type_node, CHREC_RIGHT (chrec_b), difference))
+ if (tree_fold_divides_p (CHREC_RIGHT (chrec_b), difference))
{
*overlaps_a = integer_zero_node;
- *overlaps_b = fold
- (build (EXACT_DIV_EXPR, integer_type_node, difference,
- CHREC_RIGHT (chrec_b)));
+ *overlaps_b = fold_build2 (EXACT_DIV_EXPR,
+ integer_type_node, difference,
+ CHREC_RIGHT (chrec_b));
*last_conflicts = integer_one_node;
return;
}
@@ -2816,7 +2812,7 @@ chrec_steps_divide_constant_p (tree chrec,
switch (TREE_CODE (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));
default:
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 3edf3e7408b..6ec112acb1b 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1432,8 +1432,8 @@ widen_bitfield (tree val, tree field, tree var)
for (i = 0, mask = 0; i < field_size; i++)
mask |= ((HOST_WIDE_INT) 1) << i;
- wide_val = build2 (BIT_AND_EXPR, TREE_TYPE (var), val,
- build_int_cst (TREE_TYPE (var), mask));
+ wide_val = fold_build2 (BIT_AND_EXPR, TREE_TYPE (var), val,
+ build_int_cst (TREE_TYPE (var), mask));
}
else
{
@@ -1443,11 +1443,11 @@ widen_bitfield (tree val, tree field, tree var)
for (i = 0, mask = 0; i < (var_size - field_size); i++)
mask |= ((HOST_WIDE_INT) 1) << (var_size - i - 1);
- wide_val = build2 (BIT_IOR_EXPR, TREE_TYPE (var), val,
- build_int_cst (TREE_TYPE (var), mask));
+ wide_val = fold_build2 (BIT_IOR_EXPR, TREE_TYPE (var), val,
+ build_int_cst (TREE_TYPE (var), mask));
}
- return fold (wide_val);
+ return wide_val;
}
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index ce4b3cf7df1..fc5491b857e 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -117,10 +117,10 @@ inverse (tree x, tree mask)
rslt = build_int_cst_type (type, 1);
for (; ctr; ctr--)
{
- rslt = fold_binary_to_constant (MULT_EXPR, type, rslt, x);
- x = fold_binary_to_constant (MULT_EXPR, type, x, x);
+ rslt = int_const_binop (MULT_EXPR, rslt, x, 0);
+ 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;
@@ -1465,14 +1465,14 @@ infer_loop_bounds_from_undefined (struct loop *loop)
utype = unsigned_type_for (type);
if (tree_int_cst_lt (step, integer_zero_node))
- diff = fold (build2 (MINUS_EXPR, utype, init,
- TYPE_MIN_VALUE (type)));
+ diff = fold_build2 (MINUS_EXPR, utype, init,
+ TYPE_MIN_VALUE (type));
else
- diff = fold (build2 (MINUS_EXPR, utype,
- TYPE_MAX_VALUE (type), init));
+ diff = fold_build2 (MINUS_EXPR, utype,
+ TYPE_MAX_VALUE (type), init);
- estimation = fold (build2 (CEIL_DIV_EXPR, utype, diff,
- step));
+ estimation = fold_build2 (CEIL_DIV_EXPR, utype, diff,
+ step);
record_estimate (loop, estimation, boolean_true_node, stmt);
}