mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-22 10:51:19 +08:00
tree-ssa-loop-niter.c (zero_p, nonzero_p): Removed.
* tree-ssa-loop-niter.c (zero_p, nonzero_p): Removed. (number_of_iterations_ne, number_of_iterations_lt_to_ne, assert_no_overflow_lt, assert_loop_rolls_lt, number_of_iterations_lt, number_of_iterations_le, number_of_iterations_cond, tree_simplify_using_condition_1, number_of_iterations_exit, find_loop_niter, loop_niter_by_eval, implies_nonnegative_p, implies_ge_p, record_nonwrapping_iv, idx_infer_loop_bounds, n_of_executions_at_most, scev_probably_wraps_p): Do not use zero_p/nonzero_p. * tree-ssa-loop-manip.c (determine_exit_conditions): Ditto. * tree-ssa-loop-ivopts.c (niter_for_exit, determine_biv_step, find_interesting_uses_op, find_interesting_uses_cond, find_interesting_uses_address, find_interesting_uses_stmt, strip_offset_1, add_candidate_1, add_old_ivs_candidates, difference_cost, determine_use_iv_cost_condition, rewrite_use_compare, remove_unused_ivs): Ditto. * tree-ssa-address.c (tree_mem_ref_addr, create_mem_ref_raw): Ditto. * tree-ssa-loop-prefetch.c (idx_analyze_ref): Ditto. * tree-cfg.c (find_taken_edge_cond_expr): Ditto. * tree.h (zero_p): Declaration removed. (null_or_integer_zerop, nonnull_and_integer_nonzerop): New. From-SVN: r120156
This commit is contained in:
parent
54129a64cd
commit
6e682d7ef0
@ -1,3 +1,27 @@
|
||||
2006-12-22 Zdenek Dvorak <dvorakz@suse.cz>
|
||||
|
||||
* tree-ssa-loop-niter.c (zero_p, nonzero_p): Removed.
|
||||
(number_of_iterations_ne, number_of_iterations_lt_to_ne,
|
||||
assert_no_overflow_lt, assert_loop_rolls_lt,
|
||||
number_of_iterations_lt, number_of_iterations_le,
|
||||
number_of_iterations_cond, tree_simplify_using_condition_1,
|
||||
number_of_iterations_exit, find_loop_niter, loop_niter_by_eval,
|
||||
implies_nonnegative_p, implies_ge_p, record_nonwrapping_iv,
|
||||
idx_infer_loop_bounds, n_of_executions_at_most, scev_probably_wraps_p):
|
||||
Do not use zero_p/nonzero_p.
|
||||
* tree-ssa-loop-manip.c (determine_exit_conditions): Ditto.
|
||||
* tree-ssa-loop-ivopts.c (niter_for_exit, determine_biv_step,
|
||||
find_interesting_uses_op, find_interesting_uses_cond,
|
||||
find_interesting_uses_address, find_interesting_uses_stmt,
|
||||
strip_offset_1, add_candidate_1, add_old_ivs_candidates,
|
||||
difference_cost, determine_use_iv_cost_condition,
|
||||
rewrite_use_compare, remove_unused_ivs): Ditto.
|
||||
* tree-ssa-address.c (tree_mem_ref_addr, create_mem_ref_raw): Ditto.
|
||||
* tree-ssa-loop-prefetch.c (idx_analyze_ref): Ditto.
|
||||
* tree-cfg.c (find_taken_edge_cond_expr): Ditto.
|
||||
* tree.h (zero_p): Declaration removed.
|
||||
(null_or_integer_zerop, nonnull_and_integer_nonzerop): New.
|
||||
|
||||
2006-12-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR middle-end/7651
|
||||
|
@ -2153,7 +2153,7 @@ find_taken_edge_cond_expr (basic_block bb, tree val)
|
||||
extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
|
||||
|
||||
gcc_assert (TREE_CODE (val) == INTEGER_CST);
|
||||
return (zero_p (val) ? false_edge : true_edge);
|
||||
return (integer_zerop (val) ? false_edge : true_edge);
|
||||
}
|
||||
|
||||
/* Given an INTEGER_CST VAL and the entry block BB to a SWITCH_EXPR
|
||||
|
@ -281,7 +281,7 @@ tree_mem_ref_addr (tree type, tree mem_ref)
|
||||
addr = act_elem;
|
||||
}
|
||||
|
||||
if (!zero_p (offset))
|
||||
if (offset && !integer_zerop (offset))
|
||||
{
|
||||
act_elem = fold_convert (type, offset);
|
||||
|
||||
@ -325,7 +325,7 @@ create_mem_ref_raw (tree type, struct mem_address *addr)
|
||||
if (addr->step && integer_onep (addr->step))
|
||||
addr->step = NULL_TREE;
|
||||
|
||||
if (addr->offset && zero_p (addr->offset))
|
||||
if (addr->offset && integer_zerop (addr->offset))
|
||||
addr->offset = NULL_TREE;
|
||||
|
||||
return build7 (TARGET_MEM_REF, type,
|
||||
|
@ -732,7 +732,7 @@ niter_for_exit (struct ivopts_data *data, edge exit)
|
||||
overlapping life ranges for them (PR 27283). */
|
||||
if (number_of_iterations_exit (data->current_loop,
|
||||
exit, &desc, true)
|
||||
&& zero_p (desc.may_be_zero)
|
||||
&& integer_zerop (desc.may_be_zero)
|
||||
&& !contains_abnormal_ssa_name_p (desc.niter))
|
||||
nfe_desc->niter = desc.niter;
|
||||
else
|
||||
@ -904,7 +904,7 @@ determine_biv_step (tree phi)
|
||||
if (!simple_iv (loop, phi, name, &iv, true))
|
||||
return NULL_TREE;
|
||||
|
||||
return (zero_p (iv.step) ? NULL_TREE : iv.step);
|
||||
return (null_or_integer_zerop (iv.step) ? NULL_TREE : iv.step);
|
||||
}
|
||||
|
||||
/* Finds basic ivs. */
|
||||
@ -1160,7 +1160,7 @@ find_interesting_uses_op (struct ivopts_data *data, tree op)
|
||||
return use;
|
||||
}
|
||||
|
||||
if (zero_p (iv->step))
|
||||
if (null_or_integer_zerop (iv->step))
|
||||
{
|
||||
record_invariant (data, op, true);
|
||||
return NULL;
|
||||
@ -1224,21 +1224,23 @@ find_interesting_uses_cond (struct ivopts_data *data, tree stmt, tree *cond_p)
|
||||
(!iv0 || !iv1)
|
||||
/* Eliminating condition based on two ivs would be nontrivial.
|
||||
??? TODO -- it is not really important to handle this case. */
|
||||
|| (!zero_p (iv0->step) && !zero_p (iv1->step)))
|
||||
|| (!null_or_integer_zerop (iv0->step)
|
||||
&& !null_or_integer_zerop (iv1->step)))
|
||||
{
|
||||
find_interesting_uses_op (data, *op0_p);
|
||||
find_interesting_uses_op (data, *op1_p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (zero_p (iv0->step) && zero_p (iv1->step))
|
||||
if (null_or_integer_zerop (iv0->step)
|
||||
&& null_or_integer_zerop (iv1->step))
|
||||
{
|
||||
/* If both are invariants, this is a work for unswitching. */
|
||||
return;
|
||||
}
|
||||
|
||||
civ = XNEW (struct iv);
|
||||
*civ = zero_p (iv0->step) ? *iv1: *iv0;
|
||||
*civ = null_or_integer_zerop (iv0->step) ? *iv1: *iv0;
|
||||
record_use (data, cond_p, civ, stmt, USE_COMPARE);
|
||||
}
|
||||
|
||||
@ -1514,7 +1516,7 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
|
||||
}
|
||||
}
|
||||
|
||||
if (zero_p (step))
|
||||
if (null_or_integer_zerop (step))
|
||||
goto fail;
|
||||
base = tree_mem_ref_addr (type, base);
|
||||
}
|
||||
@ -1524,7 +1526,7 @@ find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
|
||||
ifs_ivopts_data.stmt = stmt;
|
||||
ifs_ivopts_data.step_p = &step;
|
||||
if (!for_each_index (&base, idx_find_step, &ifs_ivopts_data)
|
||||
|| zero_p (step))
|
||||
|| null_or_integer_zerop (step))
|
||||
goto fail;
|
||||
|
||||
gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF);
|
||||
@ -1598,7 +1600,7 @@ find_interesting_uses_stmt (struct ivopts_data *data, tree stmt)
|
||||
|
||||
iv = get_iv (data, lhs);
|
||||
|
||||
if (iv && !zero_p (iv->step))
|
||||
if (iv && !null_or_integer_zerop (iv->step))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1644,7 +1646,7 @@ find_interesting_uses_stmt (struct ivopts_data *data, tree stmt)
|
||||
lhs = PHI_RESULT (stmt);
|
||||
iv = get_iv (data, lhs);
|
||||
|
||||
if (iv && !zero_p (iv->step))
|
||||
if (iv && !null_or_integer_zerop (iv->step))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1758,7 +1760,7 @@ strip_offset_1 (tree expr, bool inside_addr, bool top_compref,
|
||||
{
|
||||
case INTEGER_CST:
|
||||
if (!cst_and_fits_in_hwi (expr)
|
||||
|| zero_p (expr))
|
||||
|| integer_zerop (expr))
|
||||
return orig_expr;
|
||||
|
||||
*offset = int_cst_value (expr);
|
||||
@ -1777,9 +1779,9 @@ strip_offset_1 (tree expr, bool inside_addr, bool top_compref,
|
||||
&& op1 == TREE_OPERAND (expr, 1))
|
||||
return orig_expr;
|
||||
|
||||
if (zero_p (op1))
|
||||
if (integer_zerop (op1))
|
||||
expr = op0;
|
||||
else if (zero_p (op0))
|
||||
else if (integer_zerop (op0))
|
||||
{
|
||||
if (code == PLUS_EXPR)
|
||||
expr = op1;
|
||||
@ -1805,7 +1807,7 @@ strip_offset_1 (tree expr, bool inside_addr, bool top_compref,
|
||||
*offset = off1 * st;
|
||||
|
||||
if (top_compref
|
||||
&& zero_p (op1))
|
||||
&& integer_zerop (op1))
|
||||
{
|
||||
/* Strip the component reference completely. */
|
||||
op0 = TREE_OPERAND (expr, 0);
|
||||
@ -1971,9 +1973,9 @@ add_candidate_1 (struct ivopts_data *data,
|
||||
if (!operand_equal_p (base, cand->iv->base, 0))
|
||||
continue;
|
||||
|
||||
if (zero_p (cand->iv->step))
|
||||
if (null_or_integer_zerop (cand->iv->step))
|
||||
{
|
||||
if (zero_p (step))
|
||||
if (null_or_integer_zerop (step))
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -2134,7 +2136,7 @@ add_old_ivs_candidates (struct ivopts_data *data)
|
||||
EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
|
||||
{
|
||||
iv = ver_info (data, i)->iv;
|
||||
if (iv && iv->biv_p && !zero_p (iv->step))
|
||||
if (iv && iv->biv_p && !null_or_integer_zerop (iv->step))
|
||||
add_old_iv_candidates (data, iv);
|
||||
}
|
||||
}
|
||||
@ -3340,10 +3342,10 @@ difference_cost (struct ivopts_data *data,
|
||||
return 0;
|
||||
}
|
||||
*var_present = true;
|
||||
if (zero_p (e2))
|
||||
if (integer_zerop (e2))
|
||||
return force_var_cost (data, e1, depends_on);
|
||||
|
||||
if (zero_p (e1))
|
||||
if (integer_zerop (e1))
|
||||
{
|
||||
cost = force_var_cost (data, e2, depends_on);
|
||||
cost += multiply_by_cost (-1, mode);
|
||||
@ -3730,7 +3732,8 @@ determine_use_iv_cost_condition (struct ivopts_data *data,
|
||||
if (TREE_CODE (cond) != SSA_NAME)
|
||||
{
|
||||
op = TREE_OPERAND (cond, 0);
|
||||
if (TREE_CODE (op) == SSA_NAME && !zero_p (get_iv (data, op)->step))
|
||||
if (TREE_CODE (op) == SSA_NAME
|
||||
&& !null_or_integer_zerop (get_iv (data, op)->step))
|
||||
op = TREE_OPERAND (cond, 1);
|
||||
if (TREE_CODE (op) == SSA_NAME)
|
||||
{
|
||||
@ -5148,7 +5151,7 @@ rewrite_use_compare (struct ivopts_data *data,
|
||||
cond = *use->op_p;
|
||||
op_p = &TREE_OPERAND (cond, 0);
|
||||
if (TREE_CODE (*op_p) != SSA_NAME
|
||||
|| zero_p (get_iv (data, *op_p)->step))
|
||||
|| null_or_integer_zerop (get_iv (data, *op_p)->step))
|
||||
op_p = &TREE_OPERAND (cond, 1);
|
||||
|
||||
op = force_gimple_operand (comp, &stmts, true, SSA_NAME_VAR (*op_p));
|
||||
@ -5219,7 +5222,7 @@ remove_unused_ivs (struct ivopts_data *data)
|
||||
|
||||
info = ver_info (data, j);
|
||||
if (info->iv
|
||||
&& !zero_p (info->iv->step)
|
||||
&& !null_or_integer_zerop (info->iv->step)
|
||||
&& !info->inv_id
|
||||
&& !info->iv->have_use_for
|
||||
&& !info->preserve_biv)
|
||||
|
@ -706,7 +706,7 @@ determine_exit_conditions (struct loop *loop, struct tree_niter_desc *desc,
|
||||
of the loop, i.e., BOUND - step * FACTOR does not overflow.
|
||||
3) # of iterations is at least FACTOR */
|
||||
|
||||
if (!zero_p (desc->may_be_zero))
|
||||
if (!integer_zerop (desc->may_be_zero))
|
||||
cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
invert_truthvalue (desc->may_be_zero),
|
||||
cond);
|
||||
|
@ -52,36 +52,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
|
||||
*/
|
||||
|
||||
/* Returns true if ARG is either NULL_TREE or constant zero. Unlike
|
||||
integer_zerop, it does not care about overflow flags. */
|
||||
|
||||
bool
|
||||
zero_p (tree arg)
|
||||
{
|
||||
if (!arg)
|
||||
return true;
|
||||
|
||||
if (TREE_CODE (arg) != INTEGER_CST)
|
||||
return false;
|
||||
|
||||
return (TREE_INT_CST_LOW (arg) == 0 && TREE_INT_CST_HIGH (arg) == 0);
|
||||
}
|
||||
|
||||
/* Returns true if ARG a nonzero constant. Unlike integer_nonzerop, it does
|
||||
not care about overflow flags. */
|
||||
|
||||
static bool
|
||||
nonzero_p (tree arg)
|
||||
{
|
||||
if (!arg)
|
||||
return false;
|
||||
|
||||
if (TREE_CODE (arg) != INTEGER_CST)
|
||||
return false;
|
||||
|
||||
return (TREE_INT_CST_LOW (arg) != 0 || TREE_INT_CST_HIGH (arg) != 0);
|
||||
}
|
||||
|
||||
/* Returns inverse of X modulo 2^s, where MASK = 2^s-1. */
|
||||
|
||||
static tree
|
||||
@ -188,7 +158,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final,
|
||||
assumption = fold_build2 (FLOOR_MOD_EXPR, niter_type, c, d);
|
||||
assumption = fold_build2 (EQ_EXPR, boolean_type_node,
|
||||
assumption, build_int_cst (niter_type, 0));
|
||||
if (!nonzero_p (assumption))
|
||||
if (!integer_nonzerop (assumption))
|
||||
niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
niter->assumptions, assumption);
|
||||
}
|
||||
@ -219,22 +189,22 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
|
||||
if (TREE_CODE (mod) != INTEGER_CST)
|
||||
return false;
|
||||
if (nonzero_p (mod))
|
||||
if (integer_nonzerop (mod))
|
||||
mod = fold_build2 (MINUS_EXPR, niter_type, step, mod);
|
||||
tmod = fold_convert (type, mod);
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
{
|
||||
/* The final value of the iv is iv1->base + MOD, assuming that this
|
||||
computation does not overflow, and that
|
||||
iv0->base <= iv1->base + MOD. */
|
||||
if (!iv1->no_overflow && !zero_p (mod))
|
||||
if (!iv1->no_overflow && !integer_zerop (mod))
|
||||
{
|
||||
bound = fold_build2 (MINUS_EXPR, type,
|
||||
TYPE_MAX_VALUE (type), tmod);
|
||||
assumption = fold_build2 (LE_EXPR, boolean_type_node,
|
||||
iv1->base, bound);
|
||||
if (zero_p (assumption))
|
||||
if (integer_zerop (assumption))
|
||||
return false;
|
||||
}
|
||||
noloop = fold_build2 (GT_EXPR, boolean_type_node,
|
||||
@ -247,13 +217,13 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
/* The final value of the iv is iv0->base - MOD, assuming that this
|
||||
computation does not overflow, and that
|
||||
iv0->base - MOD <= iv1->base. */
|
||||
if (!iv0->no_overflow && !zero_p (mod))
|
||||
if (!iv0->no_overflow && !integer_zerop (mod))
|
||||
{
|
||||
bound = fold_build2 (PLUS_EXPR, type,
|
||||
TYPE_MIN_VALUE (type), tmod);
|
||||
assumption = fold_build2 (GE_EXPR, boolean_type_node,
|
||||
iv0->base, bound);
|
||||
if (zero_p (assumption))
|
||||
if (integer_zerop (assumption))
|
||||
return false;
|
||||
}
|
||||
noloop = fold_build2 (GT_EXPR, boolean_type_node,
|
||||
@ -262,11 +232,11 @@ number_of_iterations_lt_to_ne (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
iv1->base);
|
||||
}
|
||||
|
||||
if (!nonzero_p (assumption))
|
||||
if (!integer_nonzerop (assumption))
|
||||
niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
niter->assumptions,
|
||||
assumption);
|
||||
if (!zero_p (noloop))
|
||||
if (!integer_zerop (noloop))
|
||||
niter->may_be_zero = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
|
||||
niter->may_be_zero,
|
||||
noloop);
|
||||
@ -286,7 +256,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
tree bound, d, assumption, diff;
|
||||
tree niter_type = TREE_TYPE (step);
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
{
|
||||
/* for (i = iv0->base; i < iv1->base; i += iv0->step) */
|
||||
if (iv0->no_overflow)
|
||||
@ -333,9 +303,9 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
iv0->base, bound);
|
||||
}
|
||||
|
||||
if (zero_p (assumption))
|
||||
if (integer_zerop (assumption))
|
||||
return false;
|
||||
if (!nonzero_p (assumption))
|
||||
if (!integer_nonzerop (assumption))
|
||||
niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
niter->assumptions, assumption);
|
||||
|
||||
@ -354,7 +324,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
tree assumption = boolean_true_node, bound, diff;
|
||||
tree mbz, mbzl, mbzr;
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
{
|
||||
diff = fold_build2 (MINUS_EXPR, type,
|
||||
iv0->step, build_int_cst (type, 1));
|
||||
@ -394,10 +364,10 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
|
||||
mbz = fold_build2 (GT_EXPR, boolean_type_node, mbzl, mbzr);
|
||||
|
||||
if (!nonzero_p (assumption))
|
||||
if (!integer_nonzerop (assumption))
|
||||
niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
niter->assumptions, assumption);
|
||||
if (!zero_p (mbz))
|
||||
if (!integer_zerop (mbz))
|
||||
niter->may_be_zero = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
|
||||
niter->may_be_zero, mbz);
|
||||
}
|
||||
@ -414,7 +384,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
tree niter_type = unsigned_type_for (type);
|
||||
tree delta, step, s;
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
{
|
||||
niter->control = *iv0;
|
||||
niter->cmp = LT_EXPR;
|
||||
@ -433,9 +403,9 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
|
||||
/* First handle the special case that the step is +-1. */
|
||||
if ((iv0->step && integer_onep (iv0->step)
|
||||
&& zero_p (iv1->step))
|
||||
&& null_or_integer_zerop (iv1->step))
|
||||
|| (iv1->step && integer_all_onesp (iv1->step)
|
||||
&& zero_p (iv0->step)))
|
||||
&& null_or_integer_zerop (iv0->step)))
|
||||
{
|
||||
/* for (i = iv0->base; i < iv1->base; i++)
|
||||
|
||||
@ -451,7 +421,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
step = fold_convert (niter_type, iv0->step);
|
||||
else
|
||||
step = fold_convert (niter_type,
|
||||
@ -509,21 +479,21 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1,
|
||||
|
||||
if (!never_infinite)
|
||||
{
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
assumption = fold_build2 (NE_EXPR, boolean_type_node,
|
||||
iv1->base, TYPE_MAX_VALUE (type));
|
||||
else
|
||||
assumption = fold_build2 (NE_EXPR, boolean_type_node,
|
||||
iv0->base, TYPE_MIN_VALUE (type));
|
||||
|
||||
if (zero_p (assumption))
|
||||
if (integer_zerop (assumption))
|
||||
return false;
|
||||
if (!nonzero_p (assumption))
|
||||
if (!integer_nonzerop (assumption))
|
||||
niter->assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
|
||||
niter->assumptions, assumption);
|
||||
}
|
||||
|
||||
if (nonzero_p (iv0->step))
|
||||
if (nonnull_and_integer_nonzerop (iv0->step))
|
||||
iv1->base = fold_build2 (PLUS_EXPR, type,
|
||||
iv1->base, build_int_cst (type, 1));
|
||||
else
|
||||
@ -572,7 +542,7 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
/* Make < comparison from > ones, and for NE_EXPR comparisons, ensure that
|
||||
the control variable is on lhs. */
|
||||
if (code == GE_EXPR || code == GT_EXPR
|
||||
|| (code == NE_EXPR && zero_p (iv0->step)))
|
||||
|| (code == NE_EXPR && null_or_integer_zerop (iv0->step)))
|
||||
{
|
||||
SWAP (iv0, iv1);
|
||||
code = swap_tree_comparison (code);
|
||||
@ -608,9 +578,9 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
|
||||
/* If the control induction variable does not overflow, the loop obviously
|
||||
cannot be infinite. */
|
||||
if (!zero_p (iv0->step) && iv0->no_overflow)
|
||||
if (!null_or_integer_zerop (iv0->step) && iv0->no_overflow)
|
||||
never_infinite = true;
|
||||
else if (!zero_p (iv1->step) && iv1->no_overflow)
|
||||
else if (!null_or_integer_zerop (iv1->step) && iv1->no_overflow)
|
||||
never_infinite = true;
|
||||
else
|
||||
never_infinite = false;
|
||||
@ -618,7 +588,7 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
/* We can handle the case when neither of the sides of the comparison is
|
||||
invariant, provided that the test is NE_EXPR. This rarely occurs in
|
||||
practice, but it is simple enough to manage. */
|
||||
if (!zero_p (iv0->step) && !zero_p (iv1->step))
|
||||
if (!null_or_integer_zerop (iv0->step) && !null_or_integer_zerop (iv1->step))
|
||||
{
|
||||
if (code != NE_EXPR)
|
||||
return false;
|
||||
@ -633,7 +603,7 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
/* If the result of the comparison is a constant, the loop is weird. More
|
||||
precise handling would be possible, but the situation is not common enough
|
||||
to waste time on it. */
|
||||
if (zero_p (iv0->step) && zero_p (iv1->step))
|
||||
if (null_or_integer_zerop (iv0->step) && null_or_integer_zerop (iv1->step))
|
||||
return false;
|
||||
|
||||
/* Ignore loops of while (i-- < 10) type. */
|
||||
@ -642,12 +612,12 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
if (iv0->step && tree_int_cst_sign_bit (iv0->step))
|
||||
return false;
|
||||
|
||||
if (!zero_p (iv1->step) && !tree_int_cst_sign_bit (iv1->step))
|
||||
if (!null_or_integer_zerop (iv1->step) && !tree_int_cst_sign_bit (iv1->step))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* If the loop exits immediately, there is nothing to do. */
|
||||
if (zero_p (fold_build2 (code, boolean_type_node, iv0->base, iv1->base)))
|
||||
if (integer_zerop (fold_build2 (code, boolean_type_node, iv0->base, iv1->base)))
|
||||
{
|
||||
niter->niter = build_int_cst (unsigned_type_for (type), 0);
|
||||
return true;
|
||||
@ -658,7 +628,7 @@ number_of_iterations_cond (tree type, affine_iv *iv0, enum tree_code code,
|
||||
switch (code)
|
||||
{
|
||||
case NE_EXPR:
|
||||
gcc_assert (zero_p (iv1->step));
|
||||
gcc_assert (null_or_integer_zerop (iv1->step));
|
||||
return number_of_iterations_ne (type, iv0, iv1->base, niter, never_infinite);
|
||||
case LT_EXPR:
|
||||
return number_of_iterations_lt (type, iv0, iv1, niter, never_infinite);
|
||||
@ -822,11 +792,11 @@ tree_simplify_using_condition_1 (tree cond, tree expr)
|
||||
/* We know that e0 == e1. Check whether we cannot simplify expr
|
||||
using this fact. */
|
||||
e = simplify_replace_tree (expr, e0, e1);
|
||||
if (zero_p (e) || nonzero_p (e))
|
||||
if (integer_zerop (e) || integer_nonzerop (e))
|
||||
return e;
|
||||
|
||||
e = simplify_replace_tree (expr, e1, e0);
|
||||
if (zero_p (e) || nonzero_p (e))
|
||||
if (integer_zerop (e) || integer_nonzerop (e))
|
||||
return e;
|
||||
}
|
||||
if (TREE_CODE (expr) == EQ_EXPR)
|
||||
@ -836,10 +806,10 @@ tree_simplify_using_condition_1 (tree cond, tree expr)
|
||||
|
||||
/* If e0 == e1 (EXPR) implies !COND, then EXPR cannot be true. */
|
||||
e = simplify_replace_tree (cond, e0, e1);
|
||||
if (zero_p (e))
|
||||
if (integer_zerop (e))
|
||||
return e;
|
||||
e = simplify_replace_tree (cond, e1, e0);
|
||||
if (zero_p (e))
|
||||
if (integer_zerop (e))
|
||||
return e;
|
||||
}
|
||||
if (TREE_CODE (expr) == NE_EXPR)
|
||||
@ -849,10 +819,10 @@ tree_simplify_using_condition_1 (tree cond, tree expr)
|
||||
|
||||
/* If e0 == e1 (!EXPR) implies !COND, then EXPR must be true. */
|
||||
e = simplify_replace_tree (cond, e0, e1);
|
||||
if (zero_p (e))
|
||||
if (integer_zerop (e))
|
||||
return boolean_true_node;
|
||||
e = simplify_replace_tree (cond, e1, e0);
|
||||
if (zero_p (e))
|
||||
if (integer_zerop (e))
|
||||
return boolean_true_node;
|
||||
}
|
||||
|
||||
@ -861,12 +831,12 @@ tree_simplify_using_condition_1 (tree cond, tree expr)
|
||||
/* Check whether COND ==> EXPR. */
|
||||
notcond = invert_truthvalue (cond);
|
||||
e = fold_binary (TRUTH_OR_EXPR, boolean_type_node, notcond, te);
|
||||
if (nonzero_p (e))
|
||||
if (e && integer_nonzerop (e))
|
||||
return e;
|
||||
|
||||
/* Check whether COND ==> not EXPR. */
|
||||
e = fold_binary (TRUTH_AND_EXPR, boolean_type_node, cond, te);
|
||||
if (e && zero_p (e))
|
||||
if (e && integer_zerop (e))
|
||||
return e;
|
||||
|
||||
return expr;
|
||||
@ -1129,8 +1099,8 @@ number_of_iterations_exit (struct loop *loop, edge exit,
|
||||
|
||||
/* We can provide a more specific warning if one of the operator is
|
||||
constant and the other advances by +1 or -1. */
|
||||
if (!zero_p (iv1.step)
|
||||
? (zero_p (iv0.step)
|
||||
if (!null_or_integer_zerop (iv1.step)
|
||||
? (null_or_integer_zerop (iv0.step)
|
||||
&& (integer_onep (iv1.step) || integer_all_onesp (iv1.step)))
|
||||
: (iv0.step
|
||||
&& (integer_onep (iv0.step) || integer_all_onesp (iv0.step))))
|
||||
@ -1176,7 +1146,7 @@ find_loop_niter (struct loop *loop, edge *exit)
|
||||
if (!number_of_iterations_exit (loop, ex, &desc, false))
|
||||
continue;
|
||||
|
||||
if (nonzero_p (desc.may_be_zero))
|
||||
if (integer_nonzerop (desc.may_be_zero))
|
||||
{
|
||||
/* We exit in the first iteration through this exit.
|
||||
We won't find anything better. */
|
||||
@ -1185,7 +1155,7 @@ find_loop_niter (struct loop *loop, edge *exit)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!zero_p (desc.may_be_zero))
|
||||
if (!integer_zerop (desc.may_be_zero))
|
||||
continue;
|
||||
|
||||
aniter = desc.niter;
|
||||
@ -1415,7 +1385,7 @@ loop_niter_by_eval (struct loop *loop, edge exit)
|
||||
aval[j] = get_val_for (op[j], val[j]);
|
||||
|
||||
acnd = fold_binary (cmp, boolean_type_node, aval[0], aval[1]);
|
||||
if (acnd && zero_p (acnd))
|
||||
if (acnd && integer_zerop (acnd))
|
||||
{
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
fprintf (dump_file,
|
||||
@ -1489,14 +1459,14 @@ implies_nonnegative_p (tree cond, tree val)
|
||||
if (tree_expr_nonnegative_p (val))
|
||||
return true;
|
||||
|
||||
if (nonzero_p (cond))
|
||||
if (integer_nonzerop (cond))
|
||||
return false;
|
||||
|
||||
compare = fold_build2 (GE_EXPR,
|
||||
boolean_type_node, val, build_int_cst (type, 0));
|
||||
compare = tree_simplify_using_condition_1 (cond, compare);
|
||||
|
||||
return nonzero_p (compare);
|
||||
return integer_nonzerop (compare);
|
||||
}
|
||||
|
||||
/* Returns true if we can prove that COND ==> A >= B. */
|
||||
@ -1506,15 +1476,15 @@ implies_ge_p (tree cond, tree a, tree b)
|
||||
{
|
||||
tree compare = fold_build2 (GE_EXPR, boolean_type_node, a, b);
|
||||
|
||||
if (nonzero_p (compare))
|
||||
if (integer_nonzerop (compare))
|
||||
return true;
|
||||
|
||||
if (nonzero_p (cond))
|
||||
if (integer_nonzerop (cond))
|
||||
return false;
|
||||
|
||||
compare = tree_simplify_using_condition_1 (cond, compare);
|
||||
|
||||
return nonzero_p (compare);
|
||||
return integer_nonzerop (compare);
|
||||
}
|
||||
|
||||
/* Returns a constant upper bound on the value of expression VAL. VAL
|
||||
@ -1711,7 +1681,7 @@ record_nonwrapping_iv (struct loop *loop, tree base, tree step, tree stmt,
|
||||
tree niter_bound, extreme, delta;
|
||||
tree type = TREE_TYPE (base), unsigned_type;
|
||||
|
||||
if (TREE_CODE (step) != INTEGER_CST || zero_p (step))
|
||||
if (TREE_CODE (step) != INTEGER_CST || integer_zerop (step))
|
||||
return;
|
||||
|
||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||
@ -1808,7 +1778,7 @@ idx_infer_loop_bounds (tree base, tree *idx, void *dta)
|
||||
if (!init
|
||||
|| !step
|
||||
|| TREE_CODE (step) != INTEGER_CST
|
||||
|| zero_p (step)
|
||||
|| integer_zerop (step)
|
||||
|| tree_contains_chrecs (init, NULL)
|
||||
|| chrec_contains_symbols_defined_in_loop (init, loop->num))
|
||||
return true;
|
||||
@ -2070,7 +2040,7 @@ n_of_executions_at_most (tree stmt,
|
||||
tree niter)
|
||||
{
|
||||
double_int bound = niter_bound->bound;
|
||||
tree nit_type = TREE_TYPE (niter);
|
||||
tree nit_type = TREE_TYPE (niter), e;
|
||||
enum tree_code cmp;
|
||||
|
||||
gcc_assert (TYPE_UNSIGNED (nit_type));
|
||||
@ -2117,9 +2087,9 @@ n_of_executions_at_most (tree stmt,
|
||||
cmp = GT_EXPR;
|
||||
}
|
||||
|
||||
return nonzero_p (fold_binary (cmp, boolean_type_node,
|
||||
niter,
|
||||
double_int_to_tree (nit_type, bound)));
|
||||
e = fold_binary (cmp, boolean_type_node,
|
||||
niter, double_int_to_tree (nit_type, bound));
|
||||
return e && integer_nonzerop (e);
|
||||
}
|
||||
|
||||
/* Returns true if the arithmetics in TYPE can be assumed not to wrap. */
|
||||
@ -2179,7 +2149,7 @@ scev_probably_wraps_p (tree base, tree step,
|
||||
|| TREE_CODE (step) != INTEGER_CST)
|
||||
return true;
|
||||
|
||||
if (zero_p (step))
|
||||
if (integer_zerop (step))
|
||||
return false;
|
||||
|
||||
/* If we can use the fact that signed and pointer arithmetics does not
|
||||
|
@ -337,7 +337,7 @@ idx_analyze_ref (tree base, tree *index, void *data)
|
||||
ibase = iv.base;
|
||||
step = iv.step;
|
||||
|
||||
if (zero_p (step))
|
||||
if (null_or_integer_zerop (step))
|
||||
istep = 0;
|
||||
else
|
||||
{
|
||||
|
17
gcc/tree.h
17
gcc/tree.h
@ -4075,7 +4075,22 @@ extern int integer_pow2p (tree);
|
||||
|
||||
extern int integer_nonzerop (tree);
|
||||
|
||||
extern bool zero_p (tree);
|
||||
/* Returns true if X is either NULL or zero. */
|
||||
|
||||
static inline bool
|
||||
null_or_integer_zerop (tree x)
|
||||
{
|
||||
return x == NULL_TREE || integer_zerop (x);
|
||||
}
|
||||
|
||||
/* Returns true if X is non-NULL and non-zero. */
|
||||
|
||||
static inline bool
|
||||
nonnull_and_integer_nonzerop (tree x)
|
||||
{
|
||||
return x != NULL_TREE && integer_nonzerop (x);
|
||||
}
|
||||
|
||||
extern bool cst_and_fits_in_hwi (tree);
|
||||
extern tree num_ending_zeros (tree);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user