On Thu, 28 Oct 2021 01:55:30 +0200
Bernhard Reutner-Fischer <rep.dot....@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..

Reply via email to