[bitmap] cleanup
Jeffrey A Law
law@redhat.com
Wed Nov 24 16:16:00 GMT 2004
On Wed, 2004-11-24 at 10:55 -0500, Andrew MacLeod wrote:
> On Wed, 2004-11-24 at 10:26, Nathan Sidwell wrote:
> > this one's been bothering me, so I decided to fix it.
> >
>
> Almost completely unrelated, but is there a reason we don't have a test
> if clear and set bitmap operation? I find I frequently use the idiom:
>
> if (!bitmap_bit_p (map, b))
> {
> bitmap_set_bit (map, b);
> <...>
> }
>
> and it seems like it would be more efficient in these cases to simply
> use something like
>
> if (bitmap_test_and_set (map, b))
> {
> <...>
> }
>
> which would avoid at least the second call to bitmap_find_bit() every
> time.
>
> Just curious if I missed something in the past...
>
No reason that I'm aware of.
I implemented it once and fixed up a several obvious places where
a tas operation could be used, but was unable to show any measurable
performance improvement. That's probably because we cache the last
referenced node in the bitmap and thus the bitmap_set operation doesn't
have to find the right node, it just does the bit twiddle.
One could argue that having a bitmap_tas is cleaner....
jeff
More information about the Gcc-patches
mailing list