summaryrefslogtreecommitdiff
path: root/gcc/bitmap.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2004-11-02 09:56:12 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2004-11-02 09:56:12 +0000
commit55994078b6bc51ae62bd4117c6c335b94336137b (patch)
tree01db73d0a68c2e2de0213a73d4f7c8d2b5d8ce66 /gcc/bitmap.c
parentf6219a5e9ca08b637e8e397eb33d7a515c9cfe7c (diff)
downloadgcc-55994078b6bc51ae62bd4117c6c335b94336137b.tar.gz
bitmap.h (bitmap_equal_p): Return bool.
* bitmap.h (bitmap_equal_p): Return bool. (bitmap_intersect_p, bitmap_intersect_compl_p): Declare. * bitmap.c (bitmap_equal_p): Return bool. Compare directly. (bitmap_intersect_p, bitmap_intersect_compl_p): New. * flow.c (calculate_global_regs_live): Use bitmap_intersect_p and bitmap_intersect_compl_p. * ifcvt (dead_or_predicable): Likewise. From-SVN: r89981
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r--gcc/bitmap.c81
1 files changed, 73 insertions, 8 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index 0a50d419ca4..c78912b28ff 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -663,20 +663,85 @@ bitmap_operation (bitmap to, bitmap from1, bitmap from2,
return changed;
}
-/* Return true if two bitmaps are identical. */
+/* Return true if two bitmaps are identical.
+ We do not bother with a check for pointer equality, as that never
+ occurs in practice. */
-int
+bool
bitmap_equal_p (bitmap a, bitmap b)
{
- bitmap_head c;
- int ret;
+ bitmap_element *a_elt;
+ bitmap_element *b_elt;
+ unsigned ix;
+
+ for (a_elt = a->first, b_elt = b->first;
+ a_elt && b_elt;
+ a_elt = a_elt->next, b_elt = b_elt->next)
+ {
+ if (a_elt->indx != b_elt->indx)
+ return false;
+ for (ix = BITMAP_ELEMENT_WORDS; ix--;)
+ if (a_elt->bits[ix] != b_elt->bits[ix])
+ return false;
+ }
+ return !a_elt && !b_elt;
+}
+
+/* Return true if A AND B is not empty. */
+
+bool
+bitmap_intersect_p (bitmap a, bitmap b)
+{
+ bitmap_element *a_elt;
+ bitmap_element *b_elt;
+ unsigned ix;
+
+ for (a_elt = a->first, b_elt = b->first;
+ a_elt && b_elt;)
+ {
+ if (a_elt->indx < b_elt->indx)
+ a_elt = a_elt->next;
+ else if (b_elt->indx < a_elt->indx)
+ b_elt = b_elt->next;
+ else
+ {
+ for (ix = BITMAP_ELEMENT_WORDS; ix--;)
+ if (a_elt->bits[ix] & b_elt->bits[ix])
+ return true;
+ a_elt = a_elt->next;
+ b_elt = b_elt->next;
+ }
+ }
+ return false;
+}
- memset (&c, 0, sizeof (c));
- ret = ! bitmap_xor (&c, a, b);
- bitmap_clear (&c);
+/* Return true if A AND NOT B is not empty. */
- return ret;
+bool
+bitmap_intersect_compl_p (bitmap a, bitmap b)
+{
+ bitmap_element *a_elt;
+ bitmap_element *b_elt;
+ unsigned ix;
+ for (a_elt = a->first, b_elt = b->first;
+ a_elt && b_elt;)
+ {
+ if (a_elt->indx < b_elt->indx)
+ return true;
+ else if (b_elt->indx < a_elt->indx)
+ b_elt = b_elt->next;
+ else
+ {
+ for (ix = BITMAP_ELEMENT_WORDS; ix--;)
+ if (a_elt->bits[ix] & ~b_elt->bits[ix])
+ return true;
+ a_elt = a_elt->next;
+ b_elt = b_elt->next;
+ }
+ }
+ return a_elt != NULL;
}
+
/* Or into bitmap TO bitmap FROM1 and'ed with the complement of
bitmap FROM2. */