From dee29e84edf944f6fa7b16d3e2d236ea81637087 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 29 Aug 2014 12:39:50 +0000 Subject: [PATCH] re PR tree-optimization/62291 (PRE uses too much memory and compile-time) 2014-08-29 Richard Biener PR tree-optimization/62291 * tree-ssa-pre.c (sorted_array_from_bitmap_set): Reserve exactly the vector size needed and use quick_push. (phi_translate_1): Adjust comment. (valid_in_sets): Remove block argument and remove pointless checking of NAMEs. (dependent_clean): Adjust for removal of block argument. (clean): Likewise. (compute_antic_aux): Likewise. (compute_partial_antic_aux): Likewise. From-SVN: r214727 --- gcc/ChangeLog | 13 +++++++++++++ gcc/tree-ssa-pre.c | 31 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 84702145719..eab1819da55 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2014-08-29 Richard Biener + + PR tree-optimization/62291 + * tree-ssa-pre.c (sorted_array_from_bitmap_set): Reserve + exactly the vector size needed and use quick_push. + (phi_translate_1): Adjust comment. + (valid_in_sets): Remove block argument and remove pointless + checking of NAMEs. + (dependent_clean): Adjust for removal of block argument. + (clean): Likewise. + (compute_antic_aux): Likewise. + (compute_partial_antic_aux): Likewise. + 2014-08-29 Alexander Ivchenko Maxim Kuznetsov Anna Tikhonova diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index f191ec05af3..ce9cf73d420 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -719,8 +719,8 @@ sorted_array_from_bitmap_set (bitmap_set_t set) bitmap_iterator bi, bj; vec result; - /* Pre-allocate roughly enough space for the array. */ - result.create (bitmap_count_bits (&set->values)); + /* Pre-allocate enough space for the array. */ + result.create (bitmap_count_bits (&set->expressions)); FOR_EACH_VALUE_ID_IN_SET (set, i, bi) { @@ -738,7 +738,7 @@ sorted_array_from_bitmap_set (bitmap_set_t set) EXECUTE_IF_SET_IN_BITMAP (exprset, 0, j, bj) { if (bitmap_bit_p (&set->expressions, j)) - result.safe_push (expression_for_id (j)); + result.quick_push (expression_for_id (j)); } } @@ -1736,8 +1736,9 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, return get_or_alloc_expr_for_name (def); } - /* Otherwise return it unchanged - it will get cleaned if its - value is not available in PREDs AVAIL_OUT set of expressions. */ + /* Otherwise return it unchanged - it will get removed if its + value is not available in PREDs AVAIL_OUT set of expressions + by the subtraction of TMP_GEN. */ return expr; } @@ -1976,14 +1977,14 @@ op_valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, tree op) For loads/calls, we also see if the vuse is killed in this block. */ static bool -valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr, - basic_block block) +valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr) { switch (expr->kind) { case NAME: - return bitmap_find_leader (AVAIL_OUT (block), - get_expr_value_id (expr)) != NULL; + /* By construction all NAMEs are available. Non-available + NAMEs are removed by subtracting TMP_GEN from the sets. */ + return true; case NARY: { unsigned int i; @@ -2021,7 +2022,7 @@ valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr, PA_IN. */ static void -dependent_clean (bitmap_set_t set1, bitmap_set_t set2, basic_block block) +dependent_clean (bitmap_set_t set1, bitmap_set_t set2) { vec exprs = sorted_array_from_bitmap_set (set1); pre_expr expr; @@ -2029,7 +2030,7 @@ dependent_clean (bitmap_set_t set1, bitmap_set_t set2, basic_block block) FOR_EACH_VEC_ELT (exprs, i, expr) { - if (!valid_in_sets (set1, set2, expr, block)) + if (!valid_in_sets (set1, set2, expr)) bitmap_remove_from_set (set1, expr); } exprs.release (); @@ -2040,7 +2041,7 @@ dependent_clean (bitmap_set_t set1, bitmap_set_t set2, basic_block block) in SET. */ static void -clean (bitmap_set_t set, basic_block block) +clean (bitmap_set_t set) { vec exprs = sorted_array_from_bitmap_set (set); pre_expr expr; @@ -2048,7 +2049,7 @@ clean (bitmap_set_t set, basic_block block) FOR_EACH_VEC_ELT (exprs, i, expr) { - if (!valid_in_sets (set, NULL, expr, block)) + if (!valid_in_sets (set, NULL, expr)) bitmap_remove_from_set (set, expr); } exprs.release (); @@ -2250,7 +2251,7 @@ compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge) bitmap_value_insert_into_set (ANTIC_IN (block), expression_for_id (bii)); - clean (ANTIC_IN (block), block); + clean (ANTIC_IN (block)); if (!bitmap_set_equal (old, ANTIC_IN (block))) { @@ -2405,7 +2406,7 @@ compute_partial_antic_aux (basic_block block, /* PA_IN[block] = PA_IN[block] - ANTIC_IN[block] */ bitmap_set_subtract_values (PA_IN (block), ANTIC_IN (block)); - dependent_clean (PA_IN (block), ANTIC_IN (block), block); + dependent_clean (PA_IN (block), ANTIC_IN (block)); if (!bitmap_set_equal (old_PA_IN, PA_IN (block))) { -- 2.30.2