summaryrefslogtreecommitdiff
path: root/unittests/ADT/BitVectorTest.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-14 15:01:19 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-14 15:01:19 +0000
commit03a3811ab48139f45cf47f1168788e630af0d40b (patch)
treee511159871ccdfc06291e52021d0f913ac171c87 /unittests/ADT/BitVectorTest.cpp
parent734dde8e051d34ac34cc58eb31cf2e6fa3ac3f37 (diff)
downloadllvm-03a3811ab48139f45cf47f1168788e630af0d40b.tar.gz
llvm-03a3811ab48139f45cf47f1168788e630af0d40b.tar.bz2
llvm-03a3811ab48139f45cf47f1168788e630af0d40b.tar.xz
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
Diffstat (limited to 'unittests/ADT/BitVectorTest.cpp')
-rw-r--r--unittests/ADT/BitVectorTest.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/unittests/ADT/BitVectorTest.cpp b/unittests/ADT/BitVectorTest.cpp
index f733e13fdf..24ce3dd22a 100644
--- a/unittests/ADT/BitVectorTest.cpp
+++ b/unittests/ADT/BitVectorTest.cpp
@@ -242,6 +242,34 @@ TEST(BitVectorTest, PortableBitMask) {
A.clearBitsNotInMask(Mask1, 1);
EXPECT_EQ(64-4u, A.count());
}
-}
+TEST(BitVectorTest, BinOps) {
+ BitVector A;
+ BitVector B;
+
+ A.resize(65);
+ EXPECT_FALSE(A.anyCommon(B));
+ EXPECT_FALSE(B.anyCommon(B));
+
+ B.resize(64);
+ A.set(64);
+ EXPECT_FALSE(A.anyCommon(B));
+ EXPECT_FALSE(B.anyCommon(A));
+
+ B.set(63);
+ EXPECT_FALSE(A.anyCommon(B));
+ EXPECT_FALSE(B.anyCommon(A));
+
+ A.set(63);
+ EXPECT_TRUE(A.anyCommon(B));
+ EXPECT_TRUE(B.anyCommon(A));
+
+ B.resize(70);
+ B.set(64);
+ B.reset(63);
+ A.resize(64);
+ EXPECT_FALSE(A.anyCommon(B));
+ EXPECT_FALSE(B.anyCommon(A));
+}
+}
#endif