diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2006-01-06 21:22:56 +0100 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2006-01-06 20:22:56 +0000 |
commit | a6f778b21e8ed7c51e7b7fea73e2105c0996095c (patch) | |
tree | 2f80a9e9f7dc377dcb9bdd829e0f2a5a8d6c28d9 /gcc/tree-ssa-loop-ivopts.c | |
parent | 782e98753b7ce46cc3fa79253d57b3365149fa54 (diff) | |
download | gcc-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-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 1e6d17ed6a0..8e1c53ad174 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -881,18 +881,16 @@ static tree determine_biv_step (tree phi) { struct loop *loop = bb_for_stmt (phi)->loop_father; - tree name = PHI_RESULT (phi), base, step; + tree name = PHI_RESULT (phi); + affine_iv iv; if (!is_gimple_reg (name)) return NULL_TREE; - if (!simple_iv (loop, phi, name, &base, &step, true)) + if (!simple_iv (loop, phi, name, &iv, true)) return NULL_TREE; - if (zero_p (step)) - return NULL_TREE; - - return step; + return (zero_p (iv.step) ? NULL_TREE : iv.step); } /* Returns true if EXP is a ssa name that occurs in an abnormal phi node. */ @@ -1044,17 +1042,16 @@ mark_bivs (struct ivopts_data *data) } /* Checks whether STMT defines a linear induction variable and stores its - parameters to BASE and STEP. */ + parameters to IV. */ static bool -find_givs_in_stmt_scev (struct ivopts_data *data, tree stmt, - tree *base, tree *step) +find_givs_in_stmt_scev (struct ivopts_data *data, tree stmt, affine_iv *iv) { tree lhs; struct loop *loop = data->current_loop; - *base = NULL_TREE; - *step = NULL_TREE; + iv->base = NULL_TREE; + iv->step = NULL_TREE; if (TREE_CODE (stmt) != MODIFY_EXPR) return false; @@ -1063,12 +1060,12 @@ find_givs_in_stmt_scev (struct ivopts_data *data, tree stmt, if (TREE_CODE (lhs) != SSA_NAME) return false; - if (!simple_iv (loop, stmt, TREE_OPERAND (stmt, 1), base, step, true)) + if (!simple_iv (loop, stmt, TREE_OPERAND (stmt, 1), iv, true)) return false; - *base = expand_simple_operations (*base); + iv->base = expand_simple_operations (iv->base); - if (contains_abnormal_ssa_name_p (*base) - || contains_abnormal_ssa_name_p (*step)) + if (contains_abnormal_ssa_name_p (iv->base) + || contains_abnormal_ssa_name_p (iv->step)) return false; return true; @@ -1079,12 +1076,12 @@ find_givs_in_stmt_scev (struct ivopts_data *data, tree stmt, static void find_givs_in_stmt (struct ivopts_data *data, tree stmt) { - tree base, step; + affine_iv iv; - if (!find_givs_in_stmt_scev (data, stmt, &base, &step)) + if (!find_givs_in_stmt_scev (data, stmt, &iv)) return; - set_iv (data, TREE_OPERAND (stmt, 0), base, step); + set_iv (data, TREE_OPERAND (stmt, 0), iv.base, iv.step); } /* Finds general ivs in basic block BB. */ |