This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Speed up bitmap iterators
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>,Zack Weinberg <zack at codesourcery dot com>
- Date: Sun, 31 Oct 2004 17:13:15 +0100
- Subject: Re: Speed up bitmap iterators
- References: <41850A54.2040302@codesourcery.com>
Hello,
> ! static inline bool
> ! bmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)
> {
> ! /* If our current word is non-zero, it contains the bit we want. */
> ! if (bi->bits)
> {
> ! next_bit:
> ! while (!(bi->bits & 1))
> {
> ! bi->bits >>= 1;
> ! *bit_no += 1;
> }
> ! return true;
> }
>
> ! /* Round up to the word boundary. We might have just iterated past
> ! the end of the last word, hence the -1. It is not possible for
> ! bit_no to point at the beginning of the now last word. */
> ! *bit_no = ((*bit_no + BITMAP_WORD_BITS - 1)
> ! / BITMAP_WORD_BITS * BITMAP_WORD_BITS);
> !
> ! /* Find the next non-zero word in this elt. */
> ! while (++bi->word_no != BITMAP_ELEMENT_WORDS)
> ! {
> ! next_word:
> ! bi->bits = bi->elt1->bits[bi->word_no];
> ! if (bi->bits)
> ! goto next_bit;
> ! *bit_no += BITMAP_WORD_BITS;
> ! }
> !
> ! /* Advance to the next element. */
> ! bi->elt1 = bi->elt1->next;
> ! if (!bi->elt1)
> ! return false;
> ! *bit_no = bi->elt1->indx * BITMAP_ELEMENT_ALL_BITS;
> ! bi->word_no = 0;
> ! goto next_word;
> ! }
is there really no way how you could write this in an easier to read
way? These gotos all around, one of them into a loop, really do not
make it simple.
Zdenek