diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-03-31 18:48:14 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-03-31 18:48:14 +0000 |
commit | e7e3560288e8d05b065b71b9b2b56deb27d45929 (patch) | |
tree | cd3d2ac852c02385c6598c04fb1d4e6500873915 /llvm/unittests/ADT/APIntTest.cpp | |
parent | d53b5b19a9529b2dc4824029f267a17d2b648191 (diff) | |
download | bcm5719-llvm-e7e3560288e8d05b065b71b9b2b56deb27d45929.tar.gz bcm5719-llvm-e7e3560288e8d05b065b71b9b2b56deb27d45929.zip |
[APInt] Rewrite getLoBits in a way that will do one less memory allocation in the multiword case. Rewrite getHiBits to use the class method version of lshr instead of the one in APIntOps. NFCI
llvm-svn: 299243
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index f05cbb9d915..51c6347cbe8 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -1958,3 +1958,21 @@ TEST(APIntTest, setAllBits) { EXPECT_EQ(128u, i128.countTrailingOnes()); EXPECT_EQ(128u, i128.countPopulation()); } + +TEST(APIntTest, getLoBits) { + APInt i32(32, 0xfa); + i32.setHighBits(1); + EXPECT_EQ(0xa, i32.getLoBits(4)); + APInt i128(128, 0xfa); + i128.setHighBits(1); + EXPECT_EQ(0xa, i128.getLoBits(4)); +} + +TEST(APIntTest, getHiBits) { + APInt i32(32, 0xfa); + i32.setHighBits(2); + EXPECT_EQ(0xc, i32.getHiBits(4)); + APInt i128(128, 0xfa); + i128.setHighBits(2); + EXPECT_EQ(0xc, i128.getHiBits(4)); +} |