diff options
author | Jeff Law <law@redhat.com> | 2017-09-29 12:20:41 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2017-09-29 12:20:41 -0600 |
commit | e9d297a15d68121ba5bdd5a76ea71c1916180622 (patch) | |
tree | ec865a0c1b998f4757f69e3cea2d7245e66f6287 /gcc/sbitmap.c | |
parent | 79310774839953f17cc5aae75ab332c788784466 (diff) | |
download | gcc-e9d297a15d68121ba5bdd5a76ea71c1916180622.zip gcc-e9d297a15d68121ba5bdd5a76ea71c1916180622.tar.gz gcc-e9d297a15d68121ba5bdd5a76ea71c1916180622.tar.bz2 |
sbitmap.c (bitmap_bit_in_range_p): New function.
* sbitmap.c (bitmap_bit_in_range_p): New function.
* sbitmap.h (bitmap_bit_in_range_p): Prototype.
* tree-ssa-dse.c (live_bytes_read): New function.
(dse_classify_store): Ignore reads of dead bytes.
* testsuite/gcc.dg/tree-ssa/ssa-dse-26.c: New test.
From-SVN: r253305
Diffstat (limited to 'gcc/sbitmap.c')
-rw-r--r-- | gcc/sbitmap.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc/sbitmap.c b/gcc/sbitmap.c index c065d13..4bf13a1 100644 --- a/gcc/sbitmap.c +++ b/gcc/sbitmap.c @@ -316,6 +316,59 @@ bitmap_set_range (sbitmap bmap, unsigned int start, unsigned int count) bmap->elms[start_word] |= mask; } +/* Return TRUE if any bit between START and END inclusive is set within + the simple bitmap BMAP. Return FALSE otherwise. */ + +bool +bitmap_bit_in_range_p (const_sbitmap bmap, unsigned int start, unsigned int end) +{ + unsigned int start_word = start / SBITMAP_ELT_BITS; + unsigned int start_bitno = start % SBITMAP_ELT_BITS; + + /* Testing within a word, starting at the beginning of a word. */ + if (start_bitno == 0 && (end - start) < SBITMAP_ELT_BITS) + { + SBITMAP_ELT_TYPE mask = ((SBITMAP_ELT_TYPE)1 << (end - start)) - 1; + return (bmap->elms[start_word] & mask) != 0; + } + + unsigned int end_word = end / SBITMAP_ELT_BITS; + unsigned int end_bitno = end % SBITMAP_ELT_BITS; + + /* Testing starts somewhere in the middle of a word. Test up to the + end of the word or the end of the requested region, whichever comes + first. */ + if (start_bitno != 0) + { + unsigned int nbits = ((start_word == end_word) + ? end_bitno - start_bitno + : SBITMAP_ELT_BITS - start_bitno); + SBITMAP_ELT_TYPE mask = ((SBITMAP_ELT_TYPE)1 << nbits) - 1; + mask <<= start_bitno; + if (bmap->elms[start_word] & mask) + return true; + start_word++; + } + + if (start_word > end_word) + return false; + + /* Now test words at a time until we hit a partial word. */ + unsigned int nwords = (end_word - start_word); + while (nwords) + { + if (bmap->elms[start_word]) + return true; + start_word++; + nwords--; + } + + /* Now handle residuals in the last word. */ + SBITMAP_ELT_TYPE mask + = ((SBITMAP_ELT_TYPE)1 << (SBITMAP_ELT_BITS - end_bitno)) - 1; + return (bmap->elms[start_word] & mask) != 0; +} + #if GCC_VERSION < 3400 /* Table of number of set bits in a character, indexed by value of char. */ static const unsigned char popcount_table[] = |