From: Richard Guenther Date: Wed, 2 Jul 2008 08:07:41 +0000 (+0000) Subject: bitmap.h (bitmap_set_bit): Return bool. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5f0d975b0d6f1d2f866ce4deab49da8f9ab13366;p=gcc.git bitmap.h (bitmap_set_bit): Return bool. 2008-07-02 Richard Guenther * bitmap.h (bitmap_set_bit): Return bool. (bitmap_clear_bit): Likewise. * bitmap.c (bitmap_set_bit): Return if the bit changed. Only write to the bitmap if it would. (bitmap_clear_bit): Likewise. * tree-ssa-structalias.c (add_implicit_graph_edge): Use bitmap_set_bit return value. (add_pred_graph_edge): Likewise. (add_graph_edge): Likewise. (do_sd_constraint): Likewise. (do_ds_constraint): Likewise. From-SVN: r137345 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe4267560fd..3f1a21e40eb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2008-07-02 Richard Guenther + + * bitmap.h (bitmap_set_bit): Return bool. + (bitmap_clear_bit): Likewise. + * bitmap.c (bitmap_set_bit): Return if the bit changed. Only + write to the bitmap if it would. + (bitmap_clear_bit): Likewise. + * tree-ssa-structalias.c (add_implicit_graph_edge): Use + bitmap_set_bit return value. + (add_pred_graph_edge): Likewise. + (add_graph_edge): Likewise. + (do_sd_constraint): Likewise. + (do_ds_constraint): Likewise. + 2008-07-02 Kaveh R. Ghazi * config/alpha/alpha.c (alpha_need_linkage, alpha_use_linkage): diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 97e60de6b3c..4fabdc915d2 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -595,9 +595,9 @@ bitmap_find_bit (bitmap head, unsigned int bit) return element; } -/* Clear a single bit in a bitmap. */ +/* Clear a single bit in a bitmap. Return true if the bit changed. */ -void +bool bitmap_clear_bit (bitmap head, int bit) { bitmap_element *const ptr = bitmap_find_bit (head, bit); @@ -606,17 +606,24 @@ bitmap_clear_bit (bitmap head, int bit) { unsigned bit_num = bit % BITMAP_WORD_BITS; unsigned word_num = bit / BITMAP_WORD_BITS % BITMAP_ELEMENT_WORDS; - ptr->bits[word_num] &= ~ (((BITMAP_WORD) 1) << bit_num); + BITMAP_WORD bit_val = ((BITMAP_WORD) 1) << bit_num; + bool res = (ptr->bits[word_num] & bit_val) != 0; + if (res) + ptr->bits[word_num] &= ~bit_val; /* If we cleared the entire word, free up the element. */ if (bitmap_element_zerop (ptr)) bitmap_element_free (head, ptr); + + return res; } + + return false; } -/* Set a single bit in a bitmap. */ +/* Set a single bit in a bitmap. Return true if the bit changed. */ -void +bool bitmap_set_bit (bitmap head, int bit) { bitmap_element *ptr = bitmap_find_bit (head, bit); @@ -630,9 +637,15 @@ bitmap_set_bit (bitmap head, int bit) ptr->indx = bit / BITMAP_ELEMENT_ALL_BITS; ptr->bits[word_num] = bit_val; bitmap_element_link (head, ptr); + return true; } else - ptr->bits[word_num] |= bit_val; + { + bool res = (ptr->bits[word_num] & bit_val) == 0; + if (res) + ptr->bits[word_num] |= bit_val; + return res; + } } /* Return whether a bit is set within a bitmap. */ diff --git a/gcc/bitmap.h b/gcc/bitmap.h index 2a3b0b4baf8..7f17dc1d361 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -136,11 +136,11 @@ extern bool bitmap_ior_and_compl (bitmap DST, const_bitmap A, const_bitmap B, co /* A |= (B & ~C). Return true if A changes. */ extern bool bitmap_ior_and_compl_into (bitmap DST, const_bitmap B, const_bitmap C); -/* Clear a single register in a register set. */ -extern void bitmap_clear_bit (bitmap, int); +/* Clear a single bit in a bitmap. Return true if the bit changed. */ +extern bool bitmap_clear_bit (bitmap, int); -/* Set a single register in a register set. */ -extern void bitmap_set_bit (bitmap, int); +/* Set a single bit in a bitmap. Return true if the bit changed. */ +extern bool bitmap_set_bit (bitmap, int); /* Return true if a register is set in a register set. */ extern int bitmap_bit_p (bitmap, int); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 57a02a4c754..e2b90c86b2e 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -904,11 +904,8 @@ add_implicit_graph_edge (constraint_graph_t graph, unsigned int to, if (!graph->implicit_preds[to]) graph->implicit_preds[to] = BITMAP_ALLOC (&predbitmap_obstack); - if (!bitmap_bit_p (graph->implicit_preds[to], from)) - { - stats.num_implicit_edges++; - bitmap_set_bit (graph->implicit_preds[to], from); - } + if (bitmap_set_bit (graph->implicit_preds[to], from)) + stats.num_implicit_edges++; } /* Add a predecessor graph edge to GRAPH, going from TO to FROM if @@ -921,8 +918,7 @@ add_pred_graph_edge (constraint_graph_t graph, unsigned int to, { if (!graph->preds[to]) graph->preds[to] = BITMAP_ALLOC (&predbitmap_obstack); - if (!bitmap_bit_p (graph->preds[to], from)) - bitmap_set_bit (graph->preds[to], from); + bitmap_set_bit (graph->preds[to], from); } /* Add a graph edge to GRAPH, going from FROM to TO if @@ -943,12 +939,11 @@ add_graph_edge (constraint_graph_t graph, unsigned int to, if (!graph->succs[from]) graph->succs[from] = BITMAP_ALLOC (&pta_obstack); - if (!bitmap_bit_p (graph->succs[from], to)) + if (bitmap_set_bit (graph->succs[from], to)) { r = true; if (to < FIRST_REF_NODE && from < FIRST_REF_NODE) stats.num_edges++; - bitmap_set_bit (graph->succs[from], to); } return r; } @@ -1405,13 +1400,11 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c, unsigned int j; bitmap_iterator bi; - if (bitmap_bit_p (delta, anything_id)) - { - flag = !bitmap_bit_p (sol, anything_id); - if (flag) - bitmap_set_bit (sol, anything_id); - goto done; - } + if (bitmap_bit_p (delta, anything_id)) + { + flag |= bitmap_set_bit (sol, anything_id); + goto done; + } /* For each variable j in delta (Sol(y)), add an edge in the graph from j to x, and union Sol(j) into Sol(x). */ @@ -1436,13 +1429,9 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c, /* Merging the solution from ESCAPED needlessly increases the set. Use ESCAPED as representative instead. Same for CALLUSED. */ - else if ((get_varinfo (t)->id == escaped_id - || get_varinfo (t)->id == callused_id) - && !bitmap_bit_p (sol, get_varinfo (t)->id)) - { - bitmap_set_bit (sol, get_varinfo (t)->id); - flag = true; - } + else if (get_varinfo (t)->id == escaped_id + || get_varinfo (t)->id == callused_id) + flag |= bitmap_set_bit (sol, get_varinfo (t)->id); else if (add_graph_edge (graph, lhs, t)) flag |= bitmap_ior_into (sol, get_varinfo (t)->solution); } @@ -1486,14 +1475,11 @@ do_ds_constraint (constraint_t c, bitmap delta) continue; t = find (v->id); - if (!bitmap_bit_p (get_varinfo (t)->solution, anything_id)) + if (bitmap_set_bit (get_varinfo (t)->solution, anything_id) + && !TEST_BIT (changed, t)) { - bitmap_set_bit (get_varinfo (t)->solution, anything_id); - if (!TEST_BIT (changed, t)) - { - SET_BIT (changed, t); - changed_count++; - } + SET_BIT (changed, t); + changed_count++; } } return;