This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [bitmap] cleanup
- From: Jeffrey A Law <law at redhat dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: Nathan Sidwell <nathan at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 24 Nov 2004 09:09:03 -0700
- Subject: Re: [bitmap] cleanup
- Organization: Red Hat, Inc
- References: <41A4A813.4080000@codesourcery.com> <1101311710.23590.12.camel@pain>
- Reply-to: law at redhat dot com
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