From 6a732743bdccfe0eac5e67d90ef5ee5fe70dfe35 Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Mon, 3 Mar 2008 11:51:36 +0000 Subject: [PATCH] tree-scalar-evolution.c (instantiate_parameters_1): An SSA_NAME defined in a loop at depth 0 is invariant. * tree-scalar-evolution.c (instantiate_parameters_1): An SSA_NAME defined in a loop at depth 0 is invariant. * tree-chrec.c (evolution_function_is_invariant_rec_p): Ditto. * tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Should never be called at loop depth 0. From-SVN: r132835 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-chrec.c | 5 +++-- gcc/tree-scalar-evolution.c | 1 + gcc/tree-ssa-loop-ivopts.c | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38741292a54..65657636a2b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2008-03-02 Sebastian Pop + + * tree-scalar-evolution.c (instantiate_parameters_1): An SSA_NAME + defined in a loop at depth 0 is invariant. + * tree-chrec.c (evolution_function_is_invariant_rec_p): Ditto. + * tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Should never + be called at loop depth 0. + 2008-03-02 Jakub Jelinek PR driver/35420 diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 37b7c0d671d..295fb7920c9 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -948,8 +948,9 @@ evolution_function_is_invariant_rec_p (tree chrec, int loopnum) if (evolution_function_is_constant_p (chrec)) return true; - if (TREE_CODE (chrec) == SSA_NAME - && expr_invariant_in_loop_p (get_loop (loopnum), chrec)) + if (TREE_CODE (chrec) == SSA_NAME + && (loopnum == 0 + || expr_invariant_in_loop_p (get_loop (loopnum), chrec))) return true; if (TREE_CODE (chrec) == POLYNOMIAL_CHREC) diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index ad8f2f0f190..4d771b7e5dd 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1971,6 +1971,7 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache /* A parameter (or loop invariant and we do not want to include evolutions in outer loops), nothing to do. */ if (!def_bb + || loop_depth (def_bb->loop_father) == 0 || (!(flags & INSERT_SUPERLOOP_CHRECS) && !flow_bb_inside_loop_p (loop, def_bb))) return chrec; diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 7bcb9810e7a..4121d821aa7 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1254,7 +1254,8 @@ find_interesting_uses_cond (struct ivopts_data *data, tree stmt, tree *cond_p) } /* Returns true if expression EXPR is obviously invariant in LOOP, - i.e. if all its operands are defined outside of the LOOP. */ + i.e. if all its operands are defined outside of the LOOP. LOOP + should not be the function body. */ bool expr_invariant_in_loop_p (struct loop *loop, tree expr) @@ -1262,6 +1263,8 @@ expr_invariant_in_loop_p (struct loop *loop, tree expr) basic_block def_bb; unsigned i, len; + gcc_assert (loop_depth (loop) > 0); + if (is_gimple_min_invariant (expr)) return true;