diff options
author | Richard Guenther <rguenther@suse.de> | 2007-11-09 14:01:33 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2007-11-09 14:01:33 +0000 |
commit | 76e910c6b72b46e017d7be9a6494113ebae72f85 (patch) | |
tree | d8b32d4da8ab288343c7d289a01fb22089dced27 /gcc/bitmap.c | |
parent | de266950570fd88e4e205bfb87bcbd7ba89b5c27 (diff) | |
download | gcc-76e910c6b72b46e017d7be9a6494113ebae72f85.zip gcc-76e910c6b72b46e017d7be9a6494113ebae72f85.tar.gz gcc-76e910c6b72b46e017d7be9a6494113ebae72f85.tar.bz2 |
bitmap.h (bitmap_single_bit_set_p): Declare.
2007-11-09 Richard Guenther <rguenther@suse.de>
* bitmap.h (bitmap_single_bit_set_p): Declare.
* bitmap.c (bitmap_single_bit_set_p): New function.
* tree-ssa-alias.c (add_may_alias_for_new_tag): Use it.
(maybe_create_global_var): Use bitmap_empty_p.
From-SVN: r130045
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r-- | gcc/bitmap.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 8b66548..c2a66f9 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -693,6 +693,40 @@ bitmap_count_bits (const_bitmap a) return count; } +/* Return true if the bitmap has a single bit set. Otherwise return + false. */ + +bool +bitmap_single_bit_set_p (const_bitmap a) +{ + unsigned long count = 0; + const bitmap_element *elt; + unsigned ix; + + if (bitmap_empty_p (a)) + return false; + + elt = a->first; + /* As there are no completely empty bitmap elements, a second one + means we have more than one bit set. */ + if (elt->next != NULL) + return false; + + for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++) + { +#if GCC_VERSION >= 3400 + /* Note that popcountl matches BITMAP_WORD in type, so the actual size + of BITMAP_WORD is not material. */ + count += __builtin_popcountl (elt->bits[ix]); +#else + count += bitmap_popcount (elt->bits[ix]); +#endif + if (count > 1) + return false; + } + + return count == 1; +} /* Return the bit number of the first set bit in the bitmap. The |