summaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2006-01-06 21:22:56 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2006-01-06 20:22:56 +0000
commita6f778b21e8ed7c51e7b7fea73e2105c0996095c (patch)
tree2f80a9e9f7dc377dcb9bdd829e0f2a5a8d6c28d9 /gcc/tree-chrec.c
parent782e98753b7ce46cc3fa79253d57b3365149fa54 (diff)
downloadgcc-a6f778b21e8ed7c51e7b7fea73e2105c0996095c.tar.gz
re PR tree-optimization/18527 (cannot determine number of iterations for loops with <=)
PR tree-optimization/18527 * tree-ssa-loop-niter.c (number_of_iterations_cond, number_of_iterations_special, number_of_iterations_exit): Move base and step of an iv to a single structure. Add no_overflow flag, and use it in # of iterations analysis. * tree-scalar-evolution.c (analyze_scalar_evolution_in_loop): Add folded_casts argument. (simple_iv): Pass base and step in a structure. Set no_overflow flag. (scev_const_prop): Add argument to analyze_scalar_evolution_in_loop. Evaluate expensiveness of computing # of iterations instead of the final expression. * tree-scalar-evolution.h (affine_iv): New structure. (simple_iv): Declaration changed. * tree-chrec.c (chrec_apply): Handle chrecs containing symbols. * tree-ssa-loop-ivopts.c (determine_biv_step, find_givs_in_stmt_scev, find_givs_in_stmt): Changed due to simple_iv change. * gcc.dg/tree-ssa/loop-15.c: New test. From-SVN: r109427
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index 0bf1d384592..30915d280ec 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -533,10 +533,9 @@ chrec_apply (unsigned var,
/* When the symbols are defined in an outer loop, it is possible
to symbolically compute the apply, since the symbols are
constants with respect to the varying loop. */
- || chrec_contains_symbols_defined_in_loop (chrec, var)
- || chrec_contains_symbols (x))
+ || chrec_contains_symbols_defined_in_loop (chrec, var))
return chrec_dont_know;
-
+
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(chrec_apply \n");
@@ -546,14 +545,10 @@ chrec_apply (unsigned var,
if (evolution_function_is_affine_p (chrec))
{
/* "{a, +, b} (x)" -> "a + b*x". */
- if (TREE_CODE (CHREC_LEFT (chrec)) == INTEGER_CST
- && integer_zerop (CHREC_LEFT (chrec)))
- res = chrec_fold_multiply (type, CHREC_RIGHT (chrec), x);
-
- else
- res = chrec_fold_plus (type, CHREC_LEFT (chrec),
- chrec_fold_multiply (type,
- CHREC_RIGHT (chrec), x));
+ x = chrec_convert (type, x, NULL_TREE);
+ res = chrec_fold_multiply (type, CHREC_RIGHT (chrec), x);
+ if (!integer_zerop (CHREC_LEFT (chrec)))
+ res = chrec_fold_plus (type, CHREC_LEFT (chrec), res);
}
else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
@@ -563,7 +558,6 @@ chrec_apply (unsigned var,
&& tree_int_cst_sgn (x) == 1)
/* testsuite/.../ssa-chrec-38.c. */
res = chrec_evaluate (var, chrec, x, 0);
-
else
res = chrec_dont_know;