summaryrefslogtreecommitdiff
path: root/gcc/bitmap.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-02 08:07:41 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-07-02 08:07:41 +0000
commitb64035d26781d55d69ea9e56fbc604258ff05e4f (patch)
tree59c464d2d8075f1ef24924d7e3cc40d4c5282472 /gcc/bitmap.c
parentd27e061f3df323d7782532ec24e71aa526eec94d (diff)
downloadgcc-b64035d26781d55d69ea9e56fbc604258ff05e4f.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137345 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r--gcc/bitmap.c25
1 files changed, 19 insertions, 6 deletions
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. */