+2008-07-02 Richard Guenther <rguenther@suse.de>
+
+ * 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 <ghazi@caip.rutgers.edu>
* config/alpha/alpha.c (alpha_need_linkage, alpha_use_linkage):
return element;
}
\f
-/* 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);
{
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);
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. */
/* 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);
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
{
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
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;
}
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). */
/* 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);
}
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;