From 553b952322f47e716baf4dd29392d4ab8bc94f98 Mon Sep 17 00:00:00 2001 From: rakdver Date: Fri, 6 Jan 2006 20:22:56 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109427 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-chrec.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'gcc/tree-chrec.c') 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; -- cgit v1.2.1