This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH V2] improve bitmap / sbitmap compatability of bitmap_set_bit
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org,tbsaunde+gcc at tbsaunde dot org
- Date: Mon, 24 Jul 2017 20:25:37 +0200
- Subject: Re: [PATCH V2] improve bitmap / sbitmap compatability of bitmap_set_bit
- Authentication-results: sourceware.org; auth=none
- References: <20170724170514.14956-1-tbsaunde+gcc@tbsaunde.org>
On July 24, 2017 7:05:14 PM GMT+02:00, tbsaunde+gcc@tbsaunde.org wrote:
>From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
>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 <tbsaunde+gcc@tbsaunde.org>
>
> * 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 <tbsaunde+gcc@tbsaunde.org>
>+
>+ * sbitmap.h (bitmap_set_bit): Return bool similar to bitmap
>+ version of this function.
>+
> 2017-07-18 Uros Bizjak <ubizjak@gmail.com>
>
> 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 = &map->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. */