This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Remove useless test in bitmap_find_bit.


I was looking at a performance regression with some threading changes I'm working on and spotted this trivial cleanup.

in bitmap_find_bit:

 /* `element' is the nearest to the one we want.  If it's not the one we
    want, the one we want doesn't exist.  */
 head->current = element;
 head->indx = element->indx;
 if (element != 0 && element->indx != indx)
   element = 0;

ELEMENT will always be non-NULL at the conditional as it was dereferenced in the prior statement. And if we look up further (not shown here), we can deduce that ELEMENT will always be non-NULL at the dereference point as well.

Things have been like this since the introduction of bitmap.c in 1997.

VRP will catch this, but its kind of silly to not clean this nit up at the source level.

Bootstrapped and regression tested on x86_64 linux.

OK for the trunk?

	* bitmap.c (bitmap_find_bit): Remove useless test.

diff --git a/gcc/bitmap.c b/gcc/bitmap.c
index 0c05512..010cf75 100644
--- a/gcc/bitmap.c
+++ b/gcc/bitmap.c
@@ -556,7 +556,7 @@ bitmap_find_bit (bitmap head, unsigned int bit)
      want, the one we want doesn't exist.  */
   head->current = element;
   head->indx = element->indx;
-  if (element != 0 && element->indx != indx)
+  if (element->indx != indx)
     element = 0;
 
   return element;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]