public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>,
	Richard Biener <richard.guenther@gmail.com>
Subject: Re: redundant bitmap_bit_p followed by bitmap_clear_bit [was: Re: [COMMITTED] Kill second order relations in the path solver.]
Date: Tue, 02 Nov 2021 18:01:21 +0000	[thread overview]
Message-ID: <mptzgqma13i.fsf@arm.com> (raw)
In-Reply-To: <CAFiYyc0AgRw7qn0-BG7s0PE3cQfhtkawwR33U=Rsnu3gfgxNXA@mail.gmail.com> (Richard Biener via Gcc-patches's message of "Tue, 2 Nov 2021 14:43:38 +0100")

Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> On Mon, Nov 1, 2021 at 10:02 PM Bernhard Reutner-Fischer via
> Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>
>> On Mon, 1 Nov 2021 15:21:03 +0100
>> Aldy Hernandez <aldyh@redhat.com> 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

  reply	other threads:[~2021-11-02 18:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 18:13 [COMMITTED] Kill second order relations in the path solver Aldy Hernandez
2021-10-27 18:13 ` [COMMITTED] Reorder relation calculating code " Aldy Hernandez
2021-10-27 18:13 ` [COMMITTED] Kill known equivalences before a new assignment " Aldy Hernandez
2021-10-27 23:55 ` [COMMITTED] Kill second order relations " Bernhard Reutner-Fischer
2021-11-01 14:10   ` redundant bitmap_bit_p followed by bitmap_clear_bit [was: Re: [COMMITTED] Kill second order relations in the path solver.] Bernhard Reutner-Fischer
2021-11-01 14:21     ` Aldy Hernandez
2021-11-01 21:02       ` Bernhard Reutner-Fischer
2021-11-02 13:43         ` Richard Biener
2021-11-02 18:01           ` Richard Sandiford [this message]
2021-11-02 21:00           ` Bernhard Reutner-Fischer
2021-11-03  8:01             ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mptzgqma13i.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rep.dot.nop@gmail.com \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).