On July 24, 2017 7:05:14 PM GMT+02:00, tbsaunde+...@tbsaunde.org wrote:
>From: Trevor Saunders
>
>This makes the sbitmap version return true if the bit was previously
>unset to make it similar to the bitmap version.
>
>I believe I fixed up the comments from may, and rebootstrapped +
>regtested
>ppc64le-linux-gnu, ok?
OK. I believe there are quite some cases that can be simplified now from
test+set to set and return value test.
Richard.
>Trev
>
>gcc/ChangeLog:
>
>2017-07-20 Trevor Saunders
>
> * sbitmap.h (bitmap_set_bit): Return bool similar to bitmap
> version of this function.
>---
> gcc/ChangeLog | 5 +
> gcc/sbitmap.h | 12
> 2 files changed, 13 insertions(+), 4 deletions(-)
>
>diff --git a/gcc/ChangeLog b/gcc/ChangeLog
>index ef0e7881073..8d171b1a8a5 100644
>--- a/gcc/ChangeLog
>+++ b/gcc/ChangeLog
>@@ -1,3 +1,8 @@
>+2017-07-20 Trevor Saunders
>+
>+ * sbitmap.h (bitmap_set_bit): Return bool similar to bitmap
>+ version of this function.
>+
> 2017-07-18 Uros Bizjak
>
> PR target/81471
>diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h
>index ce4d27d927c..6f90fc877d4 100644
>--- a/gcc/sbitmap.h
>+++ b/gcc/sbitmap.h
>@@ -104,13 +104,17 @@ bitmap_bit_p (const_sbitmap map, int bitno)
> return (map->elms[i] >> s) & (SBITMAP_ELT_TYPE) 1;
> }
>
>-/* Set bit number BITNO in the sbitmap MAP. */
>+/* Set bit number BITNO in the sbitmap MAP. Return true if it was
>+ previously unset. */
>
>-static inline void
>+static inline bool
> bitmap_set_bit (sbitmap map, int bitno)
> {
>- map->elms[bitno / SBITMAP_ELT_BITS]
>-|= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
>+ SBITMAP_ELT_TYPE *word = >elms[bitno / SBITMAP_ELT_BITS];
>+ SBITMAP_ELT_TYPE mask = (SBITMAP_ELT_TYPE) 1 << (bitno) %
>SBITMAP_ELT_BITS;
>+ bool ret = (*word & mask) == 0;
>+ *word |= mask;
>+ return ret;
> }
>
> /* Reset bit number BITNO in the sbitmap MAP. */