From 4d4b1b30cd402e5bea4f54234a1206060a5155e4 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 4 Sep 2012 15:25:38 +0000 Subject: [PATCH] tree-ssa-pre.c (value_expressions): Make it a vector of bitmaps containing expression IDs. 2012-09-04 Richard Guenther * tree-ssa-pre.c (value_expressions): Make it a vector of bitmaps containing expression IDs. (add_to_value): Adjust. (sorted_array_from_bitmap_set): Likewise. (bitmap_set_replace_value): Likewise. (print_value_expressions): Likewise. (get_constant_for_value_id): Likewise. (get_representative_for): Likewise. (phi_translate_1): Likewise. (bitmap_find_leader): Likewise. (find_or_generate_expression): Likewise. (do_regular_insertion): Likewise. (init_pre): Likewise. (fini_pre): Likewise. From-SVN: r190938 --- gcc/ChangeLog | 17 ++++++++++++ gcc/tree-ssa-pre.c | 76 ++++++++++++++++++++++++++---------------------------- 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c605432..cc3a2ed 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2012-09-04 Richard Guenther + + * tree-ssa-pre.c (value_expressions): Make it a vector of + bitmaps containing expression IDs. + (add_to_value): Adjust. + (sorted_array_from_bitmap_set): Likewise. + (bitmap_set_replace_value): Likewise. + (print_value_expressions): Likewise. + (get_constant_for_value_id): Likewise. + (get_representative_for): Likewise. + (phi_translate_1): Likewise. + (bitmap_find_leader): Likewise. + (find_or_generate_expression): Likewise. + (do_regular_insertion): Likewise. + (init_pre): Likewise. + (fini_pre): Likewise. + 2012-09-04 Diego Novillo PR bootstrap/54479 diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 38abbdd..bb1a03d 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -368,9 +368,7 @@ typedef struct bitmap_set EXECUTE_IF_SET_IN_BITMAP(&(set)->values, 0, (id), (bi)) /* Mapping from value id to expressions with that value_id. */ -DEF_VEC_P (bitmap_set_t); -DEF_VEC_ALLOC_P (bitmap_set_t, heap); -static VEC(bitmap_set_t, heap) *value_expressions; +static VEC(bitmap, heap) *value_expressions; /* Sets that we need to keep track of. */ typedef struct bb_bitmap_sets @@ -580,24 +578,23 @@ phi_trans_add (pre_expr e, pre_expr v, basic_block pred) static void add_to_value (unsigned int v, pre_expr e) { - bitmap_set_t set; + bitmap set; - gcc_assert (get_expr_value_id (e) == v); + gcc_checking_assert (get_expr_value_id (e) == v); - if (v >= VEC_length (bitmap_set_t, value_expressions)) + if (v >= VEC_length (bitmap, value_expressions)) { - VEC_safe_grow_cleared (bitmap_set_t, heap, value_expressions, - v + 1); + VEC_safe_grow_cleared (bitmap, heap, value_expressions, v + 1); } - set = VEC_index (bitmap_set_t, value_expressions, v); + set = VEC_index (bitmap, value_expressions, v); if (!set) { - set = bitmap_set_new (); - VEC_replace (bitmap_set_t, value_expressions, v, set); + set = BITMAP_ALLOC (&grand_bitmap_obstack); + VEC_replace (bitmap, value_expressions, v, set); } - bitmap_insert_into_set_1 (set, e, v, true); + bitmap_set_bit (set, get_or_alloc_expression_id (e)); } /* Create a new bitmap set and return it. */ @@ -717,8 +714,8 @@ sorted_array_from_bitmap_set (bitmap_set_t set) If this is somehow a significant lose for some cases, we can choose which set to walk based on the set size. */ - bitmap_set_t exprset = VEC_index (bitmap_set_t, value_expressions, i); - FOR_EACH_EXPR_ID_IN_SET (exprset, j, bj) + bitmap exprset = VEC_index (bitmap, value_expressions, i); + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, j, bj) { if (bitmap_bit_p (&set->expressions, j)) VEC_safe_push (pre_expr, heap, result, expression_for_id (j)); @@ -824,7 +821,7 @@ static void bitmap_set_replace_value (bitmap_set_t set, unsigned int lookfor, const pre_expr expr) { - bitmap_set_t exprset; + bitmap exprset; unsigned int i; bitmap_iterator bi; @@ -843,8 +840,8 @@ bitmap_set_replace_value (bitmap_set_t set, unsigned int lookfor, 5-10x faster than walking the bitmap. If this is somehow a significant lose for some cases, we can choose which set to walk based on the set size. */ - exprset = VEC_index (bitmap_set_t, value_expressions, lookfor); - FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi) + exprset = VEC_index (bitmap, value_expressions, lookfor); + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, i, bi) { if (bitmap_clear_bit (&set->expressions, i)) { @@ -1042,12 +1039,14 @@ debug_bitmap_sets_for (basic_block bb) static void print_value_expressions (FILE *outfile, unsigned int val) { - bitmap_set_t set = VEC_index (bitmap_set_t, value_expressions, val); + bitmap set = VEC_index (bitmap, value_expressions, val); if (set) { + bitmap_set x; char s[10]; sprintf (s, "%04d", val); - print_bitmap_set (outfile, set, s, 0); + x.expressions = *set; + print_bitmap_set (outfile, &x, s, 0); } } @@ -1095,9 +1094,9 @@ get_constant_for_value_id (unsigned int v) { unsigned int i; bitmap_iterator bi; - bitmap_set_t exprset = VEC_index (bitmap_set_t, value_expressions, v); + bitmap exprset = VEC_index (bitmap, value_expressions, v); - FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi) + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, i, bi) { pre_expr expr = expression_for_id (i); if (expr->kind == CONSTANT) @@ -1377,9 +1376,8 @@ get_representative_for (const pre_expr e) and pick out an SSA_NAME. */ unsigned int i; bitmap_iterator bi; - bitmap_set_t exprs = VEC_index (bitmap_set_t, value_expressions, - value_id); - FOR_EACH_EXPR_ID_IN_SET (exprs, i, bi) + bitmap exprs = VEC_index (bitmap, value_expressions, value_id); + EXECUTE_IF_SET_IN_BITMAP (exprs, 0, i, bi) { pre_expr rep = expression_for_id (i); if (rep->kind == NAME) @@ -1499,7 +1497,7 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, else { new_val_id = get_next_value_id (); - VEC_safe_grow_cleared (bitmap_set_t, heap, + VEC_safe_grow_cleared (bitmap, heap, value_expressions, get_max_value_id() + 1); nary = vn_nary_op_insert_pieces (newnary->length, @@ -1698,7 +1696,7 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, if (changed || !same_valid) { new_val_id = get_next_value_id (); - VEC_safe_grow_cleared (bitmap_set_t, heap, + VEC_safe_grow_cleared (bitmap, heap, value_expressions, get_max_value_id() + 1); } @@ -1851,9 +1849,9 @@ bitmap_find_leader (bitmap_set_t set, unsigned int val, gimple stmt) { unsigned int i; bitmap_iterator bi; - bitmap_set_t exprset = VEC_index (bitmap_set_t, value_expressions, val); + bitmap exprset = VEC_index (bitmap, value_expressions, val); - FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi) + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, i, bi) { pre_expr expr = expression_for_id (i); if (expr->kind == CONSTANT) @@ -1875,10 +1873,9 @@ bitmap_find_leader (bitmap_set_t set, unsigned int val, gimple stmt) choose which set to walk based on which set is smaller. */ unsigned int i; bitmap_iterator bi; - bitmap_set_t exprset = VEC_index (bitmap_set_t, value_expressions, val); + bitmap exprset = VEC_index (bitmap, value_expressions, val); - EXECUTE_IF_AND_IN_BITMAP (&exprset->expressions, - &set->expressions, 0, i, bi) + EXECUTE_IF_AND_IN_BITMAP (exprset, &set->expressions, 0, i, bi) { pre_expr val = expression_for_id (i); /* At the point where stmt is not null, there should always @@ -2916,14 +2913,14 @@ find_or_generate_expression (basic_block block, pre_expr expr, if (genop == NULL && !domstmt) { - bitmap_set_t exprset; + bitmap exprset; unsigned int lookfor = get_expr_value_id (expr); bool handled = false; bitmap_iterator bi; unsigned int i; - exprset = VEC_index (bitmap_set_t, value_expressions, lookfor); - FOR_EACH_EXPR_ID_IN_SET (exprset, i, bi) + exprset = VEC_index (bitmap, value_expressions, lookfor); + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, i, bi) { pre_expr temp = expression_for_id (i); if (temp->kind != NAME) @@ -3542,11 +3539,10 @@ do_regular_insertion (basic_block block, basic_block dom) { unsigned int j; bitmap_iterator bi; - bitmap_set_t exprset = VEC_index (bitmap_set_t, - value_expressions, val); + bitmap exprset = VEC_index (bitmap, value_expressions, val); unsigned int new_val = get_expr_value_id (edoubleprime); - FOR_EACH_EXPR_ID_IN_SET (exprset, j, bi) + EXECUTE_IF_SET_IN_BITMAP (exprset, 0, j, bi) { pre_expr expr = expression_for_id (j); @@ -4780,8 +4776,8 @@ init_pre (bool do_fre) next_expression_id = 1; expressions = NULL; VEC_safe_push (pre_expr, heap, expressions, (pre_expr)NULL); - value_expressions = VEC_alloc (bitmap_set_t, heap, get_max_value_id () + 1); - VEC_safe_grow_cleared (bitmap_set_t, heap, value_expressions, + value_expressions = VEC_alloc (bitmap, heap, get_max_value_id () + 1); + VEC_safe_grow_cleared (bitmap, heap, value_expressions, get_max_value_id() + 1); name_to_id = NULL; @@ -4833,7 +4829,7 @@ fini_pre (bool do_fre) bool do_ab_cleanup = !bitmap_empty_p (need_ab_cleanup); free (postorder); - VEC_free (bitmap_set_t, heap, value_expressions); + VEC_free (bitmap, heap, value_expressions); BITMAP_FREE (inserted_exprs); bitmap_obstack_release (&grand_bitmap_obstack); free_alloc_pool (bitmap_set_pool); -- 2.7.4