bitmap.c (bitmap_find_bit): Speed up by traversing from head->first if that seems...
authorKazu Hirata <kazu@cs.umass.edu>
Fri, 26 Nov 2004 07:07:00 +0000 (07:07 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Fri, 26 Nov 2004 07:07:00 +0000 (07:07 +0000)
* bitmap.c (bitmap_find_bit): Speed up by traversing from
head->first if that seems profitable.

From-SVN: r91335

gcc/ChangeLog
gcc/bitmap.c

index 6ed23714c4bfee6e929b281e758bd599dab37d29..af309768113dc3e6204c1bb54300d9b599f8688a 100644 (file)
@@ -3,6 +3,9 @@
        * cfgrtl.c (try_redirect_by_replacing_jump): Speed up the
        check that tests if all edges go to the same destination.
 
+       * bitmap.c (bitmap_find_bit): Speed up by traversing from
+       head->first if that seems profitable.
+
 2004-11-25  Jeff Law  <law@redhat.com>
 
        * timevar.def (TV_TREE_LOOP_INIT, TV_TREE_LOOP_FINI): New timevars.
index f633505eeba153539687eab527ae05351c61e28e..140dd007e7968c5cb4da8727283fb8ed1bad426c 100644 (file)
@@ -401,14 +401,26 @@ bitmap_find_bit (bitmap head, unsigned int bit)
       || head->indx == indx)
     return head->current;
 
-  if (head->indx > indx)
+  if (head->indx < indx)
+    /* INDX is beyond head->indx.  Search from head->current
+       forward.  */
+    for (element = head->current;
+        element->next != 0 && element->indx < indx;
+        element = element->next)
+      ;
+
+  else if (head->indx / 2 < indx)
+    /* INDX is less than head->indx and closer to head->indx than to
+       0.  Search from head->current backward.  */
     for (element = head->current;
         element->prev != 0 && element->indx > indx;
         element = element->prev)
       ;
 
   else
-    for (element = head->current;
+    /* INDX is less than head->indx and closer to 0 than to
+       head->indx.  Search from head->first forward.  */
+    for (element = head->first;
         element->next != 0 && element->indx < indx;
         element = element->next)
       ;