public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA] Remove useless test in bitmap_find_bit.
@ 2016-05-06 21:18 Jeff Law
  2016-05-09  9:29 ` Bernd Schmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2016-05-06 21:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

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?


[-- Attachment #2: P --]
[-- Type: text/plain, Size: 451 bytes --]

	* 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-20 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-06 21:18 [RFA] Remove useless test in bitmap_find_bit Jeff Law
2016-05-09  9:29 ` Bernd Schmidt
2016-05-20 21:34   ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).