Add BitVector::anyCommon().

The existing operation (A & B).any() is very slow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2012-05-14 15:01:19 +00:00
parent 734dde8e05
commit 03a3811ab4
2 changed files with 39 additions and 1 deletions

View File

@@ -272,6 +272,16 @@ public:
return (*this)[Idx];
}
/// Test if any common bits are set.
bool anyCommon(const BitVector &RHS) const {
unsigned ThisWords = NumBitWords(size());
unsigned RHSWords = NumBitWords(RHS.size());
for (unsigned i = 0, e = std::min(ThisWords, RHSWords); i != e; ++i)
if (Bits[i] & RHS.Bits[i])
return true;
return false;
}
// Comparison operators.
bool operator==(const BitVector &RHS) const {
unsigned ThisWords = NumBitWords(size());