summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit2fad493fe4182078f75c030fa7fc04b20dc17814 (patch)
tree33a7b36bdd8dc189662240dc32669f8cda858097 /llvm/unittests/ADT/BitVectorTest.cpp
parentf5cbda29cdb9c868f27dfa03ebe76103ca0a2dc5 (diff)
downloadbcm5719-llvm-2fad493fe4182078f75c030fa7fc04b20dc17814.tar.gz
bcm5719-llvm-2fad493fe4182078f75c030fa7fc04b20dc17814.zip
Add BitVector::anyCommon().
The existing operation (A & B).any() is very slow. llvm-svn: 156760
Diffstat (limited to 'llvm/unittests/ADT/BitVectorTest.cpp')
-rw-r--r--llvm/unittests/ADT/BitVectorTest.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/BitVectorTest.cpp b/llvm/unittests/ADT/BitVectorTest.cpp
index f733e13fdfc..24ce3dd22a2 100644
--- a/llvm/unittests/ADT/BitVectorTest.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud