[PATCH] Improve PR91257, specialize bitmap_ior_and_compl_into
Richard Biener
rguenther@suse.de
Tue Jul 30 10:21:00 GMT 2019
bitmap_ior_and_compl_into is currently doing bitmap_and_compl into
a temporary bitmap and then bitmap_ior_into. The following uses
the existing implementation of bitmap_ior_and_into and exchanges
the core worker based on a template parameter.
This results in a slight savings in out-of-SSA time (it also avoids
using the default obstack for the temporary while all operands for
out-of-SSA and the result live in different obstacks).
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2019-07-30 Richard Biener <rguenther@suse.de>
PR tree-optimization/91257
* bitmap.c (bitmap_ior_and_maybe_compl): New templated function
based on bitmap_ior_and_into.
(bitmap_ior_and_into): Wrap around bitmap_ior_and_maybe_compl.
(bitmap_ior_and_compl_into): Likewise.
Index: gcc/bitmap.c
===================================================================
--- gcc/bitmap.c (revision 273795)
+++ gcc/bitmap.c (working copy)
@@ -2345,28 +2399,11 @@ bitmap_ior_and_compl (bitmap dst, const_
return changed;
}
-/* A |= (B & ~C). Return true if A changes. */
+/* Helper for A |= (B & ~C) and A |= (B & C). Return true if A changes. */
-bool
-bitmap_ior_and_compl_into (bitmap a, const_bitmap b, const_bitmap c)
-{
- bitmap_head tmp;
- bool changed;
-
- gcc_checking_assert (!a->tree_form && !b->tree_form && !c->tree_form);
-
- bitmap_initialize (&tmp, &bitmap_default_obstack);
- bitmap_and_compl (&tmp, b, c);
- changed = bitmap_ior_into (a, &tmp);
- bitmap_clear (&tmp);
-
- return changed;
-}
-
-/* A |= (B & C). Return true if A changes. */
-
-bool
-bitmap_ior_and_into (bitmap a, const_bitmap b, const_bitmap c)
+template <bool compl_p>
+static bool
+bitmap_ior_and_maybe_compl_into (bitmap a, const_bitmap b, const_bitmap c)
{
bitmap_element *a_elt = a->first;
const bitmap_element *b_elt = b->first;
@@ -2408,11 +2445,18 @@ bitmap_ior_and_into (bitmap a, const_bit
overall = 0;
and_elt.indx = b_elt->indx;
- for (ix = 0; ix < BITMAP_ELEMENT_WORDS; ix++)
- {
- and_elt.bits[ix] = b_elt->bits[ix] & c_elt->bits[ix];
- overall |= and_elt.bits[ix];
- }
+ if (compl_p)
+ for (ix = 0; ix < BITMAP_ELEMENT_WORDS; ix++)
+ {
+ and_elt.bits[ix] = b_elt->bits[ix] & ~c_elt->bits[ix];
+ overall |= and_elt.bits[ix];
+ }
+ else
+ for (ix = 0; ix < BITMAP_ELEMENT_WORDS; ix++)
+ {
+ and_elt.bits[ix] = b_elt->bits[ix] & c_elt->bits[ix];
+ overall |= and_elt.bits[ix];
+ }
b_elt = b_elt->next;
c_elt = c_elt->next;
@@ -2444,6 +2488,22 @@ bitmap_ior_and_into (bitmap a, const_bit
return changed;
}
+/* A |= (B & ~C). Return true if A changes. */
+
+bool
+bitmap_ior_and_compl_into (bitmap a, const_bitmap b, const_bitmap c)
+{
+ return bitmap_ior_and_maybe_compl_into<true> (a, b, c);
+}
+
+/* A |= (B & C). Return true if A changes. */
+
+bool
+bitmap_ior_and_into (bitmap a, const_bitmap b, const_bitmap c)
+{
+ return bitmap_ior_and_maybe_compl_into<false> (a, b, c);
+}
+
/* Compute hash of bitmap (for purposes of hashing). */
hashval_t
More information about the Gcc-patches
mailing list