summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/MathExtrasTest.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2019-10-14 09:04:15 +0000
committerGuillaume Chatelet <gchatelet@google.com>2019-10-14 09:04:15 +0000
commit415df89e22abe3defa06cbc901a173e5a6791f8d (patch)
tree54343abb421641828de2c16a49a7452563be0606 /llvm/unittests/Support/MathExtrasTest.cpp
parent52bfa73af841bbbcee0ea59577c9d7b4bd9831d5 (diff)
downloadbcm5719-llvm-415df89e22abe3defa06cbc901a173e5a6791f8d.tar.gz
bcm5719-llvm-415df89e22abe3defa06cbc901a173e5a6791f8d.zip
[Alignment][NFC] Support compile time constants
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68936 llvm-svn: 374758
Diffstat (limited to 'llvm/unittests/Support/MathExtrasTest.cpp')
-rw-r--r--llvm/unittests/Support/MathExtrasTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/Support/MathExtrasTest.cpp b/llvm/unittests/Support/MathExtrasTest.cpp
index 01c83c9e14d..e910d83b626 100644
--- a/llvm/unittests/Support/MathExtrasTest.cpp
+++ b/llvm/unittests/Support/MathExtrasTest.cpp
@@ -203,6 +203,25 @@ TEST(MathExtras, PowerOf2Floor) {
EXPECT_EQ(4U, PowerOf2Floor(7U));
}
+TEST(MathExtras, CTLog2) {
+ EXPECT_EQ(CTLog2<1ULL << 0>(), 0U);
+ EXPECT_EQ(CTLog2<1ULL << 1>(), 1U);
+ EXPECT_EQ(CTLog2<1ULL << 2>(), 2U);
+ EXPECT_EQ(CTLog2<1ULL << 3>(), 3U);
+ EXPECT_EQ(CTLog2<1ULL << 4>(), 4U);
+ EXPECT_EQ(CTLog2<1ULL << 5>(), 5U);
+ EXPECT_EQ(CTLog2<1ULL << 6>(), 6U);
+ EXPECT_EQ(CTLog2<1ULL << 7>(), 7U);
+ EXPECT_EQ(CTLog2<1ULL << 8>(), 8U);
+ EXPECT_EQ(CTLog2<1ULL << 9>(), 9U);
+ EXPECT_EQ(CTLog2<1ULL << 10>(), 10U);
+ EXPECT_EQ(CTLog2<1ULL << 11>(), 11U);
+ EXPECT_EQ(CTLog2<1ULL << 12>(), 12U);
+ EXPECT_EQ(CTLog2<1ULL << 13>(), 13U);
+ EXPECT_EQ(CTLog2<1ULL << 14>(), 14U);
+ EXPECT_EQ(CTLog2<1ULL << 15>(), 15U);
+}
+
TEST(MathExtras, ByteSwap_32) {
EXPECT_EQ(0x44332211u, ByteSwap_32(0x11223344));
EXPECT_EQ(0xDDCCBBAAu, ByteSwap_32(0xAABBCCDD));
OpenPOWER on IntegriCloud