extern bool bitmap_set_bit (bitmap, int);
/* Return true if a bit is set in a bitmap. */
-extern int bitmap_bit_p (const_bitmap, int);
+extern bool bitmap_bit_p (const_bitmap, int);
/* Set and get multiple bit values in a sparse bitmap. This allows a bitmap to
function as a sparse array of bit patterns where the patterns are
}
/* Test if bit number bitno in the bitmap is set. */
-static inline SBITMAP_ELT_TYPE
+static inline bool
bitmap_bit_p (const_sbitmap map, int bitno)
{
bitmap_check_index (map, bitno);
return (map->elms[i] >> s) & (SBITMAP_ELT_TYPE) 1;
}
-/* Set bit number BITNO in the sbitmap MAP. */
+/* Set bit number BITNO in the sbitmap MAP.
+ Return true if the bit changed. */
-static inline void
+static inline bool
bitmap_set_bit (sbitmap map, int bitno)
{
bitmap_check_index (map, bitno);
- map->elms[bitno / SBITMAP_ELT_BITS]
- |= (SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS;
+ size_t i = bitno / SBITMAP_ELT_BITS;
+ unsigned int s = bitno % SBITMAP_ELT_BITS;
+ if (map->elms[i] & ((SBITMAP_ELT_TYPE) 1 << s))
+ return false;
+ map->elms[i] |= (SBITMAP_ELT_TYPE) 1 << s;
+ return true;
}
-/* Reset bit number BITNO in the sbitmap MAP. */
+/* Reset bit number BITNO in the sbitmap MAP.
+ Return true if the bit changed. */
-static inline void
+static inline bool
bitmap_clear_bit (sbitmap map, int bitno)
{
bitmap_check_index (map, bitno);
- map->elms[bitno / SBITMAP_ELT_BITS]
- &= ~((SBITMAP_ELT_TYPE) 1 << (bitno) % SBITMAP_ELT_BITS);
+ size_t i = bitno / SBITMAP_ELT_BITS;
+ unsigned int s = bitno % SBITMAP_ELT_BITS;
+ if (!(map->elms[i] & ((SBITMAP_ELT_TYPE) 1 << s)))
+ return false;
+ map->elms[i] &= ~((SBITMAP_ELT_TYPE) 1 << s);
+ return true;
}
/* The iterator for sbitmap. */
{
bool err = false;
- if (bitmap_bit_p (visited, bb->index))
+ if (!bitmap_set_bit (visited, bb->index))
return false;
- bitmap_set_bit (visited, bb->index);
-
/* Pick up the single virtual PHI def. */
gphi *phi = NULL;
for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);