aboutsummaryrefslogtreecommitdiff
path: root/gcc/bitmap.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-07-02 08:07:41 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-07-02 08:07:41 +0000
commit5f0d975b0d6f1d2f866ce4deab49da8f9ab13366 (patch)
tree59c464d2d8075f1ef24924d7e3cc40d4c5282472 /gcc/bitmap.c
parent78209f30ad17a26e21acecbb5ed518c747f28c74 (diff)
downloadgcc-5f0d975b0d6f1d2f866ce4deab49da8f9ab13366.zip
gcc-5f0d975b0d6f1d2f866ce4deab49da8f9ab13366.tar.gz
gcc-5f0d975b0d6f1d2f866ce4deab49da8f9ab13366.tar.bz2
bitmap.h (bitmap_set_bit): Return bool.
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. From-SVN: r137345
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 97e60de..4fabdc9 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. */