Richard Biener via Gcc-patches <[email protected]> writes:
> On Mon, Nov 1, 2021 at 10:02 PM Bernhard Reutner-Fischer via
> Gcc-patches <[email protected]> wrote:
>>
>> On Mon, 1 Nov 2021 15:21:03 +0100
>> Aldy Hernandez <[email protected]> wrote:
>>
>> > I'm not convinced this makes the code clearer to read, especially if
>> > it's not on a critical path. But if you feel strongly, please submit
>> > a patch ;-).
>>
>> No i don't feel strongly about it.
>> Compiling e.g. -O2 ira.o
>> # Overhead Samples Command Shared Object Symbol
>> # ........ ............ ....... ............. .........................
>> #
>> 100.00% 4197 cc1plus cc1plus [.] mark_reachable_blocks
>> 100.00% 22000 cc1plus cc1plus [.]
>> path_oracle::killing_def
>> and the mark_elimination is reload.
>> So it's not just a handful of calls saved but some. And it would be
>> smaller code as it saves a call. Well maybe another day.
>
> Note that single bit set/clear are already implemented as test && set/clear.
> Note that unfortunately the sbitmap bitmap_set/clear_bit overloads do not
> return the previous state of the bit.
+1 that it would good if the sbitmap versions behaved like the bitmap
versions. Always low-key bothered me that they didn't do this when I
hit it, but never got round to do anything about it...
Bitmap operations consistently show up high in the profiles, so IMO
using the return value of bitmap_set_bit and bitmap_clear_bit should be
the preferred style. Not all uses are performance-critical, of course,
but code tends to get copied around. Having all code do it the fast
way reduces the risk that slow code gets copied to code that needs
to be fast. :-)
> Maybe providing bitmap_test_and_set_bit () and
> bitmap_test_and_clear_bit () would be better (but note we currently
> return true when the bit changed, not when it was set).
Yeah, maybe it's just familiarity, but I find the:
if (bitmap_set_bit (bb, i))
...something changed...
thing easier to follow than:
if (!bitmap_test_and_set_bit (bb, i))
...something changed...
Thanks,
Richard