This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Speed up bitmap iterators


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]