bitmap.h (nBITMAP_WORD_BITS): Remove.

* bitmap.h (nBITMAP_WORD_BITS): Remove.
	(BITMAP_WORD_BITS): Force unsigned by use of 1u.
	(BITMAP_ELEMENT_WORDS, BITMAP_ELEMENT_ALL_BITS): Remove
	unnecessary casts.
	(bitmap_first_set_bit): Return unsigned, use ctzl.
	(bitmap_last_set_bit): Remove.
	* bitmap.c (bitmap_element_zerop, bitmap_copy): Make iterator
	unsigned.
	(bitmap_first_set_bit): Return unsigned, require non-empty bitmap,
	remove special case code for two word elements.
	(bitmap_last_set_bit): Remove.
	* ra-build.c (livethrough_conflicts_bb): Replace unnecessary use of
	bitmap_first_set_bit with bitmap_empty_p.
	* tree-outof-ssa.c (analyze_edges_for_bb): Likewise.
	* tree-ssa-pre.c (bitmap_print_value): Use simple flag rather than
	bitmap_last_bit_set.

From-SVN: r90478
This commit is contained in:
Nathan Sidwell 2004-11-11 10:36:27 +00:00 committed by Nathan Sidwell
parent af2a91bdce
commit 65a6f34265
6 changed files with 74 additions and 116 deletions

View File

@ -1,3 +1,22 @@
2004-11-11 Nathan Sidwell <nathan@codesourcery.com>
* bitmap.h (nBITMAP_WORD_BITS): Remove.
(BITMAP_WORD_BITS): Force unsigned by use of 1u.
(BITMAP_ELEMENT_WORDS, BITMAP_ELEMENT_ALL_BITS): Remove
unnecessary casts.
(bitmap_first_set_bit): Return unsigned, use ctzl.
(bitmap_last_set_bit): Remove.
* bitmap.c (bitmap_element_zerop, bitmap_copy): Make iterator
unsigned.
(bitmap_first_set_bit): Return unsigned, require non-empty bitmap,
remove special case code for two word elements.
(bitmap_last_set_bit): Remove.
* ra-build.c (livethrough_conflicts_bb): Replace unnecessary use of
bitmap_first_set_bit with bitmap_empty_p.
* tree-outof-ssa.c (analyze_edges_for_bb): Likewise.
* tree-ssa-pre.c (bitmap_print_value): Use simple flag rather than
bitmap_last_bit_set.
2004-11-11 Nathan Sidwell <nathan@codesourcery.com>
PR target/16796

View File

@ -174,7 +174,7 @@ bitmap_element_zerop (bitmap_element *element)
#if BITMAP_ELEMENT_WORDS == 2
return (element->bits[0] | element->bits[1]) == 0;
#else
int i;
unsigned i;
for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
if (element->bits[i] != 0)
@ -309,7 +309,7 @@ bitmap_copy (bitmap to, bitmap from)
{
bitmap_element *from_ptr, *to_ptr = 0;
#if BITMAP_ELEMENT_WORDS != 2
int i;
unsigned i;
#endif
bitmap_clear (to);
@ -444,112 +444,55 @@ bitmap_bit_p (bitmap head, int bit)
return (ptr->bits[word_num] >> bit_num) & 1;
}
/* Return the bit number of the first set bit in the bitmap, or -1
if the bitmap is empty. */
/* Return the bit number of the first set bit in the bitmap. The
bitmap must be non-empty. */
int
unsigned
bitmap_first_set_bit (bitmap a)
{
bitmap_element *ptr = a->first;
bitmap_element *elt = a->first;
unsigned bit_no;
BITMAP_WORD word;
unsigned word_num, bit_num;
if (ptr == NULL)
return -1;
#if BITMAP_ELEMENT_WORDS == 2
word_num = 0, word = ptr->bits[0];
if (word == 0)
word_num = 1, word = ptr->bits[1];
#else
for (word_num = 0; word_num < BITMAP_ELEMENT_WORDS; ++word_num)
if ((word = ptr->bits[word_num]) != 0)
goto word_found;
unsigned ix;
gcc_assert (elt);
bit_no = elt->indx * BITMAP_ELEMENT_ALL_BITS;
for (ix = 0; ix != BITMAP_ELEMENT_WORDS; ix++)
{
word = elt->bits[ix];
if (word)
goto found_bit;
}
gcc_unreachable ();
word_found:
#endif
found_bit:
bit_no += ix * BITMAP_WORD_BITS;
#if GCC_VERSION >= 3004
gcc_assert (sizeof(long) == sizeof (word));
bit_no += __builtin_ctzl (word);
#else
/* Binary search for the first set bit. */
/* ??? It'd be nice to know if ffs or ffsl was available. */
bit_num = 0;
word = word & -word;
#if nBITMAP_WORD_BITS > 64
#error "Fill out the table."
#if BITMAP_WORD_BITS > 64
#error "Fill out the table."
#endif
#if nBITMAP_WORD_BITS > 32
if ((word & 0xffffffff) == 0)
word >>= 32, bit_num += 32;
#if BITMAP_WORD_BITS > 32
if (!(word & 0xffffffff))
word >>= 32, bit_no += 32;
#endif
if ((word & 0xffff) == 0)
word >>= 16, bit_num += 16;
if ((word & 0xff) == 0)
word >>= 8, bit_num += 8;
if (word & 0xf0)
bit_num += 4;
if (word & 0xcc)
bit_num += 2;
if (word & 0xaa)
bit_num += 1;
return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ word_num * BITMAP_WORD_BITS
+ bit_num);
}
/* Return the bit number of the last set bit in the bitmap, or -1
if the bitmap is empty. */
int
bitmap_last_set_bit (bitmap a)
{
bitmap_element *ptr = a->first;
BITMAP_WORD word;
unsigned word_num, bit_num;
if (ptr == NULL)
return -1;
while (ptr->next != NULL)
ptr = ptr->next;
#if BITMAP_ELEMENT_WORDS == 2
word_num = 1, word = ptr->bits[1];
if (word == 0)
word_num = 0, word = ptr->bits[0];
#else
for (word_num = BITMAP_ELEMENT_WORDS; word_num-- > 0; )
if ((word = ptr->bits[word_num]) != 0)
goto word_found;
gcc_unreachable ();
word_found:
if (!(word & 0xffff))
word >>= 16, bit_no += 16;
if (!(word & 0xff))
word >>= 8, bit_no += 8;
if (!(word & 0xf))
word >>= 4, bit_no += 4;
if (!(word & 0x3))
word >>= 2, bit_no += 2;
if (!(word & 0x1))
word >>= 1, bit_no += 1;
gcc_assert (word & 1);
#endif
/* Binary search for the last set bit. */
bit_num = 0;
#if nBITMAP_WORD_BITS > 64
#error "Fill out the table."
#endif
#if nBITMAP_WORD_BITS > 32
if (word & ~(BITMAP_WORD)0xffffffff)
word >>= 32, bit_num += 32;
#endif
if (word & 0xffff0000)
word >>= 16, bit_num += 16;
if (word & 0xff00)
word >>= 8, bit_num += 8;
if (word & 0xf0)
word >>= 4, bit_num += 4;
if (word & 0xc)
word >>= 2, bit_num += 2;
if (word & 0x2)
bit_num += 1;
return (ptr->indx * BITMAP_ELEMENT_ALL_BITS
+ word_num * BITMAP_WORD_BITS
+ bit_num);
return bit_no;
}

View File

@ -24,24 +24,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* Fundamental storage type for bitmap. */
/* typedef unsigned HOST_WIDE_INT BITMAP_WORD; */
/* #define nBITMAP_WORD_BITS HOST_BITS_PER_WIDE_INT */
typedef unsigned long BITMAP_WORD;
#define nBITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG)
#define BITMAP_WORD_BITS (unsigned) nBITMAP_WORD_BITS
/* BITMAP_WORD_BITS needs to be unsigned, but cannot contain casts as
it is used in preprocessor directives -- hence the 1u. */
#define BITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG * 1u)
/* Number of words to use for each element in the linked list. */
#ifndef BITMAP_ELEMENT_WORDS
#define BITMAP_ELEMENT_WORDS ((128 + nBITMAP_WORD_BITS - 1) / nBITMAP_WORD_BITS)
#define BITMAP_ELEMENT_WORDS ((128 + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS)
#endif
/* Number of bits in each actual element of a bitmap. We get slightly better
code for bit % BITMAP_ELEMENT_ALL_BITS and bit / BITMAP_ELEMENT_ALL_BITS if
bits is unsigned, assuming it is a power of 2. */
/* Number of bits in each actual element of a bitmap. */
#define BITMAP_ELEMENT_ALL_BITS \
((unsigned) (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS))
#define BITMAP_ELEMENT_ALL_BITS (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS)
/* Bitmap set element. We use a linked list to hold only the bits that
are set. This allows for use to grow the bitset dynamically without
@ -132,8 +128,7 @@ extern void bitmap_release_memory (void);
/* A few compatibility/functions macros for compatibility with sbitmaps */
#define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
#define bitmap_zero(a) bitmap_clear (a)
extern int bitmap_first_set_bit (bitmap);
extern int bitmap_last_set_bit (bitmap);
extern unsigned bitmap_first_set_bit (bitmap);
/* Allocate a bitmap with oballoc. */
#define BITMAP_OBSTACK_ALLOC(OBSTACK) \

View File

@ -1022,13 +1022,12 @@ livethrough_conflicts_bb (basic_block bb)
struct ra_bb_info *info = (struct ra_bb_info *) bb->aux;
rtx insn;
bitmap all_defs;
int first;
unsigned use_id;
unsigned int deaths = 0;
unsigned int contains_call = 0;
/* If there are no deferred uses, just return. */
if ((first = bitmap_first_set_bit (info->live_throughout)) < 0)
if (bitmap_empty_p (info->live_throughout))
return;
/* First collect the IDs of all defs, count the number of death
@ -1061,7 +1060,7 @@ livethrough_conflicts_bb (basic_block bb)
{
bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (info->live_throughout, first, use_id, bi)
EXECUTE_IF_SET_IN_BITMAP (info->live_throughout, 0, use_id, bi)
{
struct web_part *wp = &web_parts[df->def_id + use_id];
unsigned int bl = rtx_to_bits (DF_REF_REG (wp->ref));

View File

@ -2094,7 +2094,7 @@ analyze_edges_for_bb (basic_block bb, FILE *debug_file)
#ifdef ENABLE_CHECKING
gcc_assert (VARRAY_ACTIVE_SIZE (edge_leader) == 0);
gcc_assert (VARRAY_ACTIVE_SIZE (stmt_list) == 0);
gcc_assert (bitmap_first_set_bit (leader_has_match) == -1);
gcc_assert (bitmap_empty_p (leader_has_match));
#endif
}

View File

@ -768,18 +768,20 @@ bitmap_print_value_set (FILE *outfile, bitmap_set_t set,
fprintf (outfile, "%s[%d] := { ", setname, blockindex);
if (set)
{
bool first;
unsigned i;
bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (set->expressions, 0, i, bi)
{
if (!first)
fprintf (outfile, ", ");
first = false;
print_generic_expr (outfile, ssa_name (i), 0);
fprintf (outfile, " (");
print_generic_expr (outfile, get_value_handle (ssa_name (i)), 0);
fprintf (outfile, ") ");
if (bitmap_last_set_bit (set->expressions) != (int)i)
fprintf (outfile, ", ");
}
}
fprintf (outfile, " }\n");