aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/KnownBitsTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Support/KnownBitsTest.cpp')
-rw-r--r--llvm/unittests/Support/KnownBitsTest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index f9631f2..d41402b 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -442,6 +442,17 @@ TEST(KnownBitsTest, CountMaxActiveBits) {
});
}
+TEST(KnownBitsTest, CountMaxSignedBits) {
+ unsigned Bits = 4;
+ ForeachKnownBits(Bits, [&](const KnownBits &Known) {
+ unsigned Expected = 0;
+ ForeachNumInKnownBits(Known, [&](const APInt &N) {
+ Expected = std::max(Expected, N.getMinSignedBits());
+ });
+ EXPECT_EQ(Expected, Known.countMaxSignedBits());
+ });
+}
+
TEST(KnownBitsTest, SExtOrTrunc) {
const unsigned NarrowerSize = 4;
const unsigned BaseSize = 6;