diff options
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index bf564d8dab5..0e372567c89 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -314,7 +314,7 @@ new_scev_info_str (basic_block instantiated_below, tree var) { struct scev_info_str *res; - res = GGC_NEW (struct scev_info_str); + res = ggc_alloc_scev_info_str (); res->var = var; res->chrec = chrec_not_analyzed_yet; res->instantiated_below = instantiated_below; @@ -1170,6 +1170,24 @@ follow_ssa_edge_expr (struct loop *loop, gimple at_stmt, tree expr, halting_phi, evolution_of_loop, limit); break; + case ADDR_EXPR: + /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR. */ + if (TREE_CODE (TREE_OPERAND (expr, 0)) == MEM_REF) + { + expr = TREE_OPERAND (expr, 0); + rhs0 = TREE_OPERAND (expr, 0); + rhs1 = TREE_OPERAND (expr, 1); + type = TREE_TYPE (rhs0); + STRIP_USELESS_TYPE_CONVERSION (rhs0); + STRIP_USELESS_TYPE_CONVERSION (rhs1); + res = follow_ssa_edge_binary (loop, at_stmt, type, + rhs0, POINTER_PLUS_EXPR, rhs1, + halting_phi, evolution_of_loop, limit); + } + else + res = t_false; + break; + case ASSERT_EXPR: /* This assignment is of the form: "a_1 = ASSERT_EXPR <a_2, ...>" It must be handled as a copy assignment of the form a_1 = a_2. */ @@ -2172,9 +2190,19 @@ instantiate_scev_name (basic_block instantiate_below, else res = chrec; - if (res == NULL_TREE - || !dominated_by_p (CDI_DOMINATORS, instantiate_below, - gimple_bb (SSA_NAME_DEF_STMT (res)))) + /* When there is no loop_closed_phi_def, it means that the + variable is not used after the loop: try to still compute the + value of the variable when exiting the loop. */ + if (res == NULL_TREE) + { + loop_p loop = loop_containing_stmt (SSA_NAME_DEF_STMT (chrec)); + res = analyze_scalar_evolution (loop, chrec); + res = compute_overall_effect_of_inner_loop (loop, res); + res = instantiate_scev_r (instantiate_below, evolution_loop, res, + fold_conversions, cache, size_expr); + } + else if (!dominated_by_p (CDI_DOMINATORS, instantiate_below, + gimple_bb (SSA_NAME_DEF_STMT (res)))) res = chrec_dont_know; } @@ -3017,12 +3045,9 @@ scev_initialize (void) loop_iterator li; struct loop *loop; - scalar_evolution_info = htab_create_alloc (100, - hash_scev_info, - eq_scev_info, - del_scev_info, - ggc_calloc, - ggc_free); + + scalar_evolution_info = htab_create_ggc (100, hash_scev_info, eq_scev_info, + del_scev_info); initialize_scalar_evolutions_analyzer (); |