From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: rep.dot.nop@gmail.com, Andrew MacLeod <amacleod@redhat.com>,
GCC patches <gcc-patches@gcc.gnu.org>
Subject: redundant bitmap_bit_p followed by bitmap_clear_bit [was: Re: [COMMITTED] Kill second order relations in the path solver.]
Date: Mon, 1 Nov 2021 15:10:27 +0100 [thread overview]
Message-ID: <20211101151027.06945d6a@nbbrfq> (raw)
In-Reply-To: <20211028015530.6fd3ee60@nbbrfq>
On Thu, 28 Oct 2021 01:55:30 +0200
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> On Wed, 27 Oct 2021 20:13:21 +0200
> Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> > @@ -1306,6 +1307,24 @@ path_oracle::killing_def (tree ssa)
> > ptr->m_next = m_equiv.m_next;
> > m_equiv.m_next = ptr;
> > bitmap_ior_into (m_equiv.m_names, b);
> > +
> > + // Walk the relation list an remove SSA from any relations.
>
> s/an /and /
>
> > + if (!bitmap_bit_p (m_relations.m_names, v))
> > + return;
> > +
> > + bitmap_clear_bit (m_relations.m_names, v);
>
> IIRC bitmap_clear_bit returns true if the bit was set, false otherwise,
> so should be used as if(!bitmap_clear_bit) above.
> > + relation_chain **prev = &(m_relations.m_head);
>
> s/[()]//
> thanks,
There seems to be two other spots where a redundant bitmap_bit_p checks
if we want to bitmap_clear_bit. In dse and ira.
Like:
$ cat ~/coccinelle/gcc_bitmap_bit_p-0.cocci ; echo EOF
// replace redundant bitmap_bit_p() bitmap_clear_bit with the latter
@ rule1 @
identifier fn;
expression bitmap, bit;
@@
fn(...) {
<...
(
-if (bitmap_bit_p (bitmap, bit))
+if (bitmap_clear_bit (bitmap, bit))
{
...
- bitmap_clear_bit (bitmap, bit);
...
}
|
-if (bitmap_bit_p (bitmap, bit))
+if (bitmap_clear_bit (bitmap, bit))
{
...
}
...
-bitmap_clear_bit (bitmap, bit);
)
...>
}
EOF
$ find gcc/ -type f -a \( -name "*.c" -o -name "*.cc" \) -a \( ! -path "gcc/testsuite/*" -a ! -path "gcc/contrib/*" \) -exec spatch -sp_file ~/coccinelle/gcc_bitmap_bit_p-0.cocci --show-diff {} \;
diff =
--- gcc/dse.c
+++ /tmp/cocci-output-1104419-443759-dse.c
@@ -3238,9 +3238,8 @@ mark_reachable_blocks (sbitmap unreachab
edge e;
edge_iterator ei;
- if (bitmap_bit_p (unreachable_blocks, bb->index))
+ if (bitmap_clear_bit(unreachable_blocks, bb->index))
{
- bitmap_clear_bit (unreachable_blocks, bb->index);
FOR_EACH_EDGE (e, ei, bb->preds)
{
mark_reachable_blocks (unreachable_blocks, e->src);
diff =
--- gcc/ira.c
+++ /tmp/cocci-output-1104678-d8679a-ira.c
@@ -2944,17 +2944,15 @@ mark_elimination (int from, int to)
FOR_EACH_BB_FN (bb, cfun)
{
r = DF_LR_IN (bb);
- if (bitmap_bit_p (r, from))
+ if (bitmap_clear_bit(r, from))
{
- bitmap_clear_bit (r, from);
bitmap_set_bit (r, to);
}
if (! df_live)
continue;
r = DF_LIVE_IN (bb);
- if (bitmap_bit_p (r, from))
+ if (bitmap_clear_bit(r, from))
{
- bitmap_clear_bit (r, from);
bitmap_set_bit (r, to);
}
}
# in ira.c one would have to fixup the curly braces manually
PS: coccinelle seems to ruin the spaces before braces in the '+' even
though i have written them correctly according to GNU style..
next prev parent reply other threads:[~2021-11-01 14:10 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 ` Bernhard Reutner-Fischer [this message]
2021-11-01 14:21 ` redundant bitmap_bit_p followed by bitmap_clear_bit [was: Re: [COMMITTED] Kill second order relations in the path solver.] Aldy Hernandez
2021-11-01 21:02 ` Bernhard Reutner-Fischer
2021-11-02 13:43 ` Richard Biener
2021-11-02 18:01 ` Richard Sandiford
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=20211101151027.06945d6a@nbbrfq \
--to=rep.dot.nop@gmail.com \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/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).