diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-05-08 04:55:09 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-05-08 04:55:09 +0000 |
commit | a51941f3140cf0ed5c79bf828ff3e418fc5df71d (patch) | |
tree | 54fc19ee211c039772021e5d0d50001100cf9d31 /llvm/unittests/ADT/APIntTest.cpp | |
parent | cd704cb6c4290643f232dc7e22b938705909dd6f (diff) | |
download | bcm5719-llvm-a51941f3140cf0ed5c79bf828ff3e418fc5df71d.tar.gz bcm5719-llvm-a51941f3140cf0ed5c79bf828ff3e418fc5df71d.zip |
[APInt] Add support for multiplying by a uint64_t.
This makes multiply similar to add, sub, xor, and, and or.
llvm-svn: 302402
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index bb6cf35fe9e..5594955e7ba 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -2142,4 +2142,23 @@ TEST(APIntTest, sext) { EXPECT_EQ(63U, i32_neg1.countPopulation()); } +TEST(APIntTest, multiply) { + APInt i64(64, 1234); + + EXPECT_EQ(7006652, i64 * 5678); + EXPECT_EQ(7006652, 5678 * i64); + + APInt i128 = APInt::getOneBitSet(128, 64); + APInt i128_1234(128, 1234); + i128_1234 <<= 64; + EXPECT_EQ(i128_1234, i128 * 1234); + EXPECT_EQ(i128_1234, 1234 * i128); + + APInt i96 = APInt::getOneBitSet(96, 64); + i96 *= ~0ULL; + EXPECT_EQ(32U, i96.countLeadingOnes()); + EXPECT_EQ(32U, i96.countPopulation()); + EXPECT_EQ(64U, i96.countTrailingZeros()); +} + } // end anonymous namespace |