diff options
author | Jason Eckhardt <jle@gcc.gnu.org> | 2000-01-29 01:41:22 +0000 |
---|---|---|
committer | Jason Eckhardt <jle@gcc.gnu.org> | 2000-01-29 01:41:22 +0000 |
commit | 65169dcfc24eafed52ff13e27421848aa8a6e44a (patch) | |
tree | b7e53416e72be71ecc8ff02e5544a3d4f9199174 /gcc/sbitmap.c | |
parent | 72af8e4e63da81d09ed612c5024c3aadfe1cd077 (diff) | |
download | gcc-65169dcfc24eafed52ff13e27421848aa8a6e44a.zip gcc-65169dcfc24eafed52ff13e27421848aa8a6e44a.tar.gz gcc-65169dcfc24eafed52ff13e27421848aa8a6e44a.tar.bz2 |
[multiple changes]
Fri Jan 7 19:48:04 CET 2000 Jan Hubicka <jh@suse.cz>
* sbitmap.c (sbitmap_first_set_bit, sbitmap_last_set_bit): New
function.
* sbitmap.h (sbitmap_first_set_bit, sbitmap_last_set_bit): Declare.
* basic_block.h (FLOW_LOOP_FIRST_BLOCK): New macro.
(FLOW_LOOP_LAST_BLOCK): Likewise.
2000-01-21 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* basic-block.h (struct loop): New fields 'first' and 'last'.
* flow.c (flow_loops_find): Compute loop->first and loop->last.
(flow_loops_dump): Use loop->first to check for NOTE_INSN_LOOP_BEG
and loop->last to check for NOTE_INSN_LOOP_END.
Fri Jan 28 10:57:58 2000 Jason Eckhardt <jle@cygnus.com>
* predict.c (estimate_probability): Use the new FIRST and LAST fields
of the loop descriptor rather than HEADER and LATCH. Also added
missing break statements as well making some coding style modifications
as suggested by Michael Hayes.
From-SVN: r31679
Diffstat (limited to 'gcc/sbitmap.c')
-rw-r--r-- | gcc/sbitmap.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c index dece5e5..0046c57 100644 --- a/gcc/sbitmap.c +++ b/gcc/sbitmap.c @@ -497,6 +497,44 @@ sbitmap_union_of_preds (dst, src, bb) } } +/* Return number of first bit set in the bitmap, -1 if none. */ + +int +sbitmap_first_set_bit (bmap) + sbitmap bmap; +{ + int n; + EXECUTE_IF_SET_IN_SBITMAP (bmap, 0, n, { return n; }); + return -1; +} + +/* Return number of last bit set in the bitmap, -1 if none. */ + +int +sbitmap_last_set_bit (bmap) + sbitmap bmap; +{ + int i; + SBITMAP_ELT_TYPE *ptr = bmap->elms; + for (i = bmap->size - 1; i >= 0; i--) + { + SBITMAP_ELT_TYPE word = ptr[i]; + if (word) + { + int index = (i + 1) * SBITMAP_ELT_BITS - 1; + SBITMAP_ELT_TYPE mask = (SBITMAP_ELT_TYPE) 1 << (SBITMAP_ELT_BITS - 1); + while (1) + { + if (word & mask) + return index; + mask >>= 1; + index--; + } + } + } + return -1; +} + void dump_sbitmap (file, bmap) FILE *file; |