From 6f929985791a50401c5e53b90d6fffc54caab43a Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Thu, 2 Jul 2015 04:32:05 +0000 Subject: [PATCH] tree-ssa-loop-ivopts.c (struct ivopts_data): New field iv_obstack. * tree-ssa-loop-ivopts.c (struct ivopts_data): New field iv_obstack. (tree_ssa_iv_optimize_init): Initialize iv_obstack. (alloc_iv): New parameter. Allocate struct iv using obstack_alloc. (set_iv, find_interesting_uses_address, add_candidate_1): New argument to alloc_iv. (find_interesting_uses_op, find_interesting_uses_cond): Don't duplicate struct iv. (free_loop_data): Don't free struct iv explicitly. (tree_ssa_iv_optimize_finalize): Free iv_obstack. From-SVN: r225293 --- gcc/ChangeLog | 12 ++++++++++++ gcc/tree-ssa-loop-ivopts.c | 33 +++++++++++++++------------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 690c2cb..c9c3c20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2015-07-02 Bin Cheng + + * tree-ssa-loop-ivopts.c (struct ivopts_data): New field iv_obstack. + (tree_ssa_iv_optimize_init): Initialize iv_obstack. + (alloc_iv): New parameter. Allocate struct iv using obstack_alloc. + (set_iv, find_interesting_uses_address, add_candidate_1): New + argument to alloc_iv. + (find_interesting_uses_op, find_interesting_uses_cond): Don't + duplicate struct iv. + (free_loop_data): Don't free struct iv explicitly. + (tree_ssa_iv_optimize_finalize): Free iv_obstack. + 2015-07-01 DJ Delorie * config/s390/tpf.h (LIBSTDCXX): Change to CPP1. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 282f874..a35ddab 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -348,6 +348,9 @@ struct ivopts_data /* The maximum invariant id. */ unsigned max_inv_id; + /* Obstack for iv structure. */ + struct obstack iv_obstack; + /* Whether to consider just related and important candidates when replacing a use. */ bool consider_all_candidates; @@ -908,6 +911,7 @@ tree_ssa_iv_optimize_init (struct ivopts_data *data) data->inv_expr_id = 0; data->name_expansion_cache = NULL; decl_rtl_to_reset.create (20); + gcc_obstack_init (&data->iv_obstack); } /* Returns a memory object to that EXPR points. In case we are able to @@ -991,10 +995,12 @@ contain_complex_addr_expr (tree expr) for loop LOOP. NO_OVERFLOW implies the iv doesn't overflow. */ static struct iv * -alloc_iv (tree base, tree step, bool no_overflow = false) +alloc_iv (struct ivopts_data *data, tree base, tree step, + bool no_overflow = false) { tree expr = base; - struct iv *iv = XCNEW (struct iv); + struct iv *iv = (struct iv*) obstack_alloc (&data->iv_obstack, + sizeof (struct iv)); gcc_assert (step != NULL_TREE); /* Lower address expression in base except ones with DECL_P as operand. @@ -1035,7 +1041,7 @@ set_iv (struct ivopts_data *data, tree iv, tree base, tree step, gcc_assert (!info->iv); bitmap_set_bit (data->relevant, SSA_NAME_VERSION (iv)); - info->iv = alloc_iv (base, step, no_overflow); + info->iv = alloc_iv (data, base, step, no_overflow); info->iv->ssa_name = iv; } @@ -1422,7 +1428,6 @@ static struct iv_use * find_interesting_uses_op (struct ivopts_data *data, tree op) { struct iv *iv; - struct iv *civ; gimple stmt; struct iv_use *use; @@ -1448,14 +1453,11 @@ find_interesting_uses_op (struct ivopts_data *data, tree op) } iv->have_use_for = true; - civ = XNEW (struct iv); - *civ = *iv; - stmt = SSA_NAME_DEF_STMT (op); gcc_assert (gimple_code (stmt) == GIMPLE_PHI || is_gimple_assign (stmt)); - use = record_use (data, NULL, civ, stmt, USE_NONLINEAR_EXPR); + use = record_use (data, NULL, iv, stmt, USE_NONLINEAR_EXPR); iv->use_id = use->id; return use; @@ -1534,7 +1536,7 @@ static void find_interesting_uses_cond (struct ivopts_data *data, gimple stmt) { tree *var_p, *bound_p; - struct iv *var_iv, *civ; + struct iv *var_iv; if (!extract_cond_operands (data, stmt, &var_p, &bound_p, &var_iv, NULL)) { @@ -1543,9 +1545,7 @@ find_interesting_uses_cond (struct ivopts_data *data, gimple stmt) return; } - civ = XNEW (struct iv); - *civ = *var_iv; - record_use (data, NULL, civ, stmt, USE_COMPARE); + record_use (data, NULL, var_iv, stmt, USE_COMPARE); } /* Returns the outermost loop EXPR is obviously invariant in @@ -2030,7 +2030,7 @@ find_interesting_uses_address (struct ivopts_data *data, gimple stmt, tree *op_p } } - civ = alloc_iv (base, step); + civ = alloc_iv (data, base, step); record_group_use (data, op_p, civ, stmt, USE_ADDRESS); return; @@ -2673,7 +2673,7 @@ add_candidate_1 (struct ivopts_data *data, if (!base && !step) cand->iv = NULL; else - cand->iv = alloc_iv (base, step); + cand->iv = alloc_iv (data, base, step); cand->pos = pos; if (pos != IP_ORIGINAL && cand->iv) @@ -7180,7 +7180,6 @@ free_loop_data (struct ivopts_data *data) struct version_info *info; info = ver_info (data, i); - free (info->iv); info->iv = NULL; info->has_nonlin_use = false; info->preserve_biv = false; @@ -7199,13 +7198,11 @@ free_loop_data (struct ivopts_data *data) gcc_assert (sub->related_cands == NULL); gcc_assert (sub->n_map_members == 0 && sub->cost_map == NULL); - free (sub->iv); pre = sub; sub = sub->next; free (pre); } - free (use->iv); BITMAP_FREE (use->related_cands); for (j = 0; j < use->n_map_members; j++) if (use->cost_map[j].depends_on) @@ -7219,7 +7216,6 @@ free_loop_data (struct ivopts_data *data) { struct iv_cand *cand = iv_cand (data, i); - free (cand->iv); if (cand->depends_on) BITMAP_FREE (cand->depends_on); free (cand); @@ -7261,6 +7257,7 @@ tree_ssa_iv_optimize_finalize (struct ivopts_data *data) delete data->inv_expr_tab; data->inv_expr_tab = NULL; free_affine_expand_cache (&data->name_expansion_cache); + obstack_free (&data->iv_obstack, NULL); } /* Returns true if the loop body BODY includes any function calls. */ -- 2.7.4