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]

[patch]: Add return flag to bitmap_and_compl_into


hi,
this patch augments bitmap_and_compl_into to return a flag indicating whether
the bitmap has changed.  When I redid the bitmap functions there were no
uses of this behaviour from the old implementation, but it appears
one of zdenek's patches (http://gcc.gnu.org/ml/gcc-patches/2003-01/msg02059.html)
would like this. Steven Bosscher is cleaning up that patch, and asked
for this functionality to be added back to bitmap_and_compl_into.

booted & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2005-02-13  Nathan Sidwell  <nathan@codesourcery.com>

	* bitmap.h (bitmap_and_compl_into): Return bool.
	* bitmap.c (bitmap_and_compl_into): Return changed flag.

Index: bitmap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.c,v
retrieving revision 1.65
diff -c -3 -p -r1.65 bitmap.c
*** bitmap.c	26 Nov 2004 07:07:00 -0000	1.65
--- bitmap.c	13 Feb 2005 16:36:07 -0000
*************** bitmap_and_compl (bitmap dst, bitmap a, 
*** 700,713 ****
      dst->indx = dst->current->indx;
  }
  
! /* A &= ~B */
  
! void
  bitmap_and_compl_into (bitmap a, bitmap b)
  {
    bitmap_element *a_elt = a->first;
    bitmap_element *b_elt = b->first;
    bitmap_element *next;
  
    gcc_assert (a != b);
    while (a_elt && b_elt)
--- 700,714 ----
      dst->indx = dst->current->indx;
  }
  
! /* A &= ~B. Returns true if A changes */
  
! bool
  bitmap_and_compl_into (bitmap a, bitmap b)
  {
    bitmap_element *a_elt = a->first;
    bitmap_element *b_elt = b->first;
    bitmap_element *next;
+   BITMAP_WORD changed = 0;
  
    gcc_assert (a != b);
    while (a_elt && b_elt)
*************** bitmap_and_compl_into (bitmap a, bitmap 
*** 724,732 ****
  
  	  for (ix = BITMAP_ELEMENT_WORDS; ix--;)
  	    {
! 	      BITMAP_WORD r = a_elt->bits[ix] & ~b_elt->bits[ix];
  
  	      a_elt->bits[ix] = r;
  	      ior |= r;
  	    }
  	  next = a_elt->next;
--- 725,735 ----
  
  	  for (ix = BITMAP_ELEMENT_WORDS; ix--;)
  	    {
! 	      BITMAP_WORD cleared = a_elt->bits[ix] & b_elt->bits[ix];
! 	      BITMAP_WORD r = a_elt->bits[ix] ^ cleared;
  
  	      a_elt->bits[ix] = r;
+ 	      changed |= cleared;
  	      ior |= r;
  	    }
  	  next = a_elt->next;
*************** bitmap_and_compl_into (bitmap a, bitmap 
*** 738,743 ****
--- 741,747 ----
      }
    gcc_assert (!a->current == !a->first);
    gcc_assert (!a->current || a->indx == a->current->indx);
+   return changed != 0;
  }
  
  /* DST = A | B.  Return true if DST changes.  */
Index: bitmap.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.h,v
retrieving revision 1.53
diff -c -3 -p -r1.53 bitmap.h
*** bitmap.h	26 Nov 2004 00:01:35 -0000	1.53
--- bitmap.h	13 Feb 2005 16:36:08 -0000
*************** extern bool bitmap_intersect_compl_p (bi
*** 102,108 ****
  extern void bitmap_and (bitmap, bitmap, bitmap);
  extern void bitmap_and_into (bitmap, bitmap);
  extern void bitmap_and_compl (bitmap, bitmap, bitmap);
! extern void bitmap_and_compl_into (bitmap, bitmap);
  extern bool bitmap_ior (bitmap, bitmap, bitmap);
  extern bool bitmap_ior_into (bitmap, bitmap);
  extern void bitmap_xor (bitmap, bitmap, bitmap);
--- 102,108 ----
  extern void bitmap_and (bitmap, bitmap, bitmap);
  extern void bitmap_and_into (bitmap, bitmap);
  extern void bitmap_and_compl (bitmap, bitmap, bitmap);
! extern bool bitmap_and_compl_into (bitmap, bitmap);
  extern bool bitmap_ior (bitmap, bitmap, bitmap);
  extern bool bitmap_ior_into (bitmap, bitmap);
  extern void bitmap_xor (bitmap, bitmap, bitmap);

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