public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4860] Make sbitmap bitmap_set_bit and bitmap_clear_bit return changed state Date: Wed, 3 Nov 2021 12:04:42 +0000 (GMT) [thread overview] Message-ID: <20211103120442.E57793858D35@sourceware.org> (raw) https://gcc.gnu.org/g:73658e70d9edfab77d7a50039b3ab7d2be3a41a0 commit r12-4860-g73658e70d9edfab77d7a50039b3ab7d2be3a41a0 Author: Richard Biener <rguenther@suse.de> Date: Wed Nov 3 09:57:21 2021 +0100 Make sbitmap bitmap_set_bit and bitmap_clear_bit return changed state The following adjusts the sbitmap bitmap_set_bit and bitmap_clear_bit APIs to match that of bitmap by returning a bool indicating whether the bitmap was changed. I've also changed bitmap_bit_p to return a bool rather than an int and made use of the sbitmap bitmap_set_bit API change in one place. 2021-11-03 Richard Biener <rguenther@suse.de> * bitmap.h (bitmap_bit_p): Change the return type to bool. * bitmap.c (bitmap_bit_p): Likewise. * sbitmap.h (bitmap_bit_p): Likewise. (bitmap_set_bit): Return whether the bit changed. (bitmap_clear_bit): Likewise. * tree-ssa.c (verify_vssa): Make use of the changed state from bitmap_set_bit. Diff: --- gcc/bitmap.c | 2 +- gcc/bitmap.h | 2 +- gcc/sbitmap.h | 28 +++++++++++++++++++--------- gcc/tree-ssa.c | 4 +--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 98c6d0b9e05..1aa8e4b3134 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -983,7 +983,7 @@ bitmap_set_bit (bitmap head, int bit) /* Return whether a bit is set within a bitmap. */ -int +bool bitmap_bit_p (const_bitmap head, int bit) { unsigned int indx = bit / BITMAP_ELEMENT_ALL_BITS; diff --git a/gcc/bitmap.h b/gcc/bitmap.h index 1bddcdbfaee..fc33877c89d 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -436,7 +436,7 @@ extern bool bitmap_clear_bit (bitmap, int); extern bool bitmap_set_bit (bitmap, int); /* Return true if a bit is set in a bitmap. */ -extern int bitmap_bit_p (const_bitmap, int); +extern bool bitmap_bit_p (const_bitmap, int); /* Set and get multiple bit values in a sparse bitmap. This allows a bitmap to function as a sparse array of bit patterns where the patterns are diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index 17660e5a65e..5fb0e005957 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @@ -114,7 +114,7 @@ bitmap_check_sizes (const_sbitmap a, const_sbitmap b) } /* Test if bit number bitno in the bitmap is set. */ -static inline SBITMAP_ELT_TYPE +static inline bool bitmap_bit_p (const_sbitmap map, int bitno) { bitmap_check_index (map, bitno); @@ -124,26 +124,36 @@ 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 the bit changed. */ -static inline void +static inline bool bitmap_set_bit (sbitmap map, int bitno) { bitmap_check_index (map, bitno); - map->elms[bitno / SBITMAP_ELT_BITS] - |= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS; + size_t i = bitno / SBITMAP_ELT_BITS; + unsigned int s = bitno % SBITMAP_ELT_BITS; + if (map->elms[i] & ((SBITMAP_ELT_TYPE) 1 << s)) + return false; + map->elms[i] |= (SBITMAP_ELT_TYPE) 1 << s; + return true; } -/* Reset bit number BITNO in the sbitmap MAP. */ +/* Reset bit number BITNO in the sbitmap MAP. + Return true if the bit changed. */ -static inline void +static inline bool bitmap_clear_bit (sbitmap map, int bitno) { bitmap_check_index (map, bitno); - map->elms[bitno / SBITMAP_ELT_BITS] - &= ~((SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS); + size_t i = bitno / SBITMAP_ELT_BITS; + unsigned int s = bitno % SBITMAP_ELT_BITS; + if (!(map->elms[i] & ((SBITMAP_ELT_TYPE) 1 << s))) + return false; + map->elms[i] &= ~((SBITMAP_ELT_TYPE) 1 << s); + return true; } /* The iterator for sbitmap. */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index fde13defebf..3f25d654d3f 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -649,11 +649,9 @@ verify_vssa (basic_block bb, tree current_vdef, sbitmap visited) { bool err = false; - if (bitmap_bit_p (visited, bb->index)) + if (!bitmap_set_bit (visited, bb->index)) return false; - bitmap_set_bit (visited, bb->index); - /* Pick up the single virtual PHI def. */ gphi *phi = NULL; for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
reply other threads:[~2021-11-03 12:04 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211103120442.E57793858D35@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).