]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
bitmap.h (bitmap_single_bit_set_p): Declare.
authorRichard Guenther <rguenther@suse.de>
Fri, 9 Nov 2007 14:01:33 +0000 (14:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 9 Nov 2007 14:01:33 +0000 (14:01 +0000)
2007-11-09  Richard Guenther  <rguenther@suse.de>

* bitmap.h (bitmap_single_bit_set_p): Declare.
* bitmap.c (bitmap_single_bit_set_p): New function.
* tree-ssa-alias.c (add_may_alias_for_new_tag): Use it.
(maybe_create_global_var): Use bitmap_empty_p.

From-SVN: r130045

gcc/ChangeLog
gcc/bitmap.c
gcc/bitmap.h
gcc/tree-ssa-alias.c

index 3fac0800a104a4c4852f4fe696e9814686b87d1b..5e44419a8171825065153f6f6a683c29c9d8dd59 100644 (file)
@@ -1,3 +1,10 @@
+2007-11-09  Richard Guenther  <rguenther@suse.de>
+
+       * bitmap.h (bitmap_single_bit_set_p): Declare.
+       * bitmap.c (bitmap_single_bit_set_p): New function.
+       * tree-ssa-alias.c (add_may_alias_for_new_tag): Use it.
+       (maybe_create_global_var): Use bitmap_empty_p.
+
 2007-11-09  Paolo Bonzini  <bonzini@gnu.org>
            Jakub Jelinek  <jakub@redhat.com>
 
index 8b66548add9bc8da2a87ec09fed01457bc270af8..c2a66f96a73f2e1bd9090b49b05f2ddd2f778c0b 100644 (file)
@@ -693,6 +693,40 @@ bitmap_count_bits (const_bitmap a)
   return count;
 }
 
+/* Return true if the bitmap has a single bit set.  Otherwise return
+   false.  */
+
+bool
+bitmap_single_bit_set_p (const_bitmap a)
+{
+  unsigned long count = 0;
+  const bitmap_element *elt;
+  unsigned ix;
+
+  if (bitmap_empty_p (a))
+    return false;
+
+  elt = a->first;
+  /* As there are no completely empty bitmap elements, a second one
+     means we have more than one bit set.  */
+  if (elt->next != NULL)
+    return false;
+
+  for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
+    {
+#if GCC_VERSION >= 3400
+      /* Note that popcountl matches BITMAP_WORD in type, so the actual size
+        of BITMAP_WORD is not material.  */
+      count += __builtin_popcountl (elt->bits[ix]);
+#else
+      count += bitmap_popcount (elt->bits[ix]);
+#endif
+      if (count > 1)
+       return false;
+    }
+
+  return count == 1;
+}
 
 
 /* Return the bit number of the first set bit in the bitmap.  The
index 66fed855afee26ed1a7a386d363e458786e031c4..0b6ed731922df5c7a1556a933042fd1a48b691a6 100644 (file)
@@ -107,6 +107,9 @@ extern bool bitmap_intersect_compl_p (const_bitmap, const_bitmap);
 /* True if MAP is an empty bitmap.  */
 #define bitmap_empty_p(MAP) (!(MAP)->first)
 
+/* True if the bitmap has only a single bit set.  */
+extern bool bitmap_single_bit_set_p (const_bitmap);
+
 /* Count the number of bits set in the bitmap.  */
 extern unsigned long bitmap_count_bits (const_bitmap);
 
index dc40c2ef398fa37ce5930a9fe64bc506a65d0942..f2e30646d4c38a9ccc0c61e7a6fdb51346545787 100644 (file)
@@ -2780,7 +2780,7 @@ maybe_create_global_var (void)
         So, if we have some pure/const and some regular calls in the
         program we create .GLOBAL_VAR to avoid missing these
         relations.  */
-      if (bitmap_count_bits (gimple_call_clobbered_vars (cfun)) == 0
+      if (bitmap_empty_p (gimple_call_clobbered_vars (cfun))
          && stats->num_call_sites > 0
          && stats->num_pure_const_call_sites > 0
          && stats->num_call_sites > stats->num_pure_const_call_sites)
@@ -3544,7 +3544,8 @@ add_may_alias_for_new_tag (tree tag, tree var)
     aliases = may_aliases (var);
 
   /* Case 1: |aliases| == 1  */
-  if (aliases && bitmap_count_bits (aliases) == 1)
+  if (aliases
+      && bitmap_single_bit_set_p (aliases))
     {
       tree ali = referenced_var (bitmap_first_set_bit (aliases));
       if (TREE_CODE (ali) == SYMBOL_MEMORY_TAG)