[mlir][LLVM] `LLVMTypeConverter`: Tighten materialization checks (#116532)
[llvm-project.git] / flang / unittests / Evaluate / leading-zero-bit-count.cpp
blob968946b69f27eadb787fa90aff967ce2d2978b07
1 #include "flang/Common/leading-zero-bit-count.h"
2 #include "testing.h"
4 using Fortran::common::LeadingZeroBitCount;
6 int main() {
7 MATCH(64, LeadingZeroBitCount(std::uint64_t{0}));
8 for (int j{0}; j < 64; ++j) {
9 for (int k{0}; k < j; ++k) {
10 std::uint64_t x = (std::uint64_t{1} << j) | (std::uint64_t{1} << k);
11 MATCH(63 - j, LeadingZeroBitCount(x))("j=%d, k=%d", j, k);
14 MATCH(32, LeadingZeroBitCount(std::uint32_t{0}));
15 for (int j{0}; j < 32; ++j) {
16 for (int k{0}; k < j; ++k) {
17 std::uint32_t x = (std::uint32_t{1} << j) | (std::uint32_t{1} << k);
18 MATCH(31 - j, LeadingZeroBitCount(x))("j=%d, k=%d", j, k);
21 MATCH(16, LeadingZeroBitCount(std::uint16_t{0}));
22 for (int j{0}; j < 16; ++j) {
23 for (int k{0}; k < j; ++k) {
24 std::uint16_t x = (std::uint16_t{1} << j) | (std::uint16_t{1} << k);
25 MATCH(15 - j, LeadingZeroBitCount(x))("j=%d, k=%d", j, k);
28 MATCH(8, LeadingZeroBitCount(std::uint8_t{0}));
29 for (int j{0}; j < 8; ++j) {
30 for (int k{0}; k < j; ++k) {
31 std::uint8_t x = (std::uint8_t{1} << j) | (std::uint8_t{1} << k);
32 MATCH(7 - j, LeadingZeroBitCount(x))("j=%d, k=%d", j, k);
35 return testing::Complete();