aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/APIntTest.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@nondot.org>2021-10-04 21:33:51 -0700
committerChris Lattner <clattner@nondot.org>2021-10-05 08:41:53 -0700
commitcc697fc292b0a405eaa42c6c8e5f117ba4f7d73b (patch)
treeabca09d0395133e0acf64071f76719d242af32d2 /llvm/unittests/ADT/APIntTest.cpp
parent6831c1d8689bebe745aac1fdd7354c2e2f692c1a (diff)
downloadllvm-cc697fc292b0a405eaa42c6c8e5f117ba4f7d73b.zip
llvm-cc697fc292b0a405eaa42c6c8e5f117ba4f7d73b.tar.gz
llvm-cc697fc292b0a405eaa42c6c8e5f117ba4f7d73b.tar.bz2
[APInt] Make insertBits and concat work with zero width APInts.
These should both clearly work with our current model for zero width integers, but don't until now! Differential Revision: https://reviews.llvm.org/D111113
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index fe7a231..59a8f4c 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1874,6 +1874,10 @@ TEST(APIntTest, insertBits) {
i63.insertBits(iSrc, 4);
EXPECT_EQ(static_cast<int64_t>(0x012345600123456Full), i63.getSExtValue());
+ // Zero width insert is a noop.
+ i31.insertBits(APInt::getZeroWidth(), 1);
+ EXPECT_EQ(static_cast<int64_t>(0x00123456ull), i31.getSExtValue());
+
// Insert single word src into one word of dst.
APInt i120(120, UINT64_MAX, true);
i120.insertBits(iSrc, 8);
@@ -2587,7 +2591,7 @@ TEST(APIntTest, truncOrSelf) {
EXPECT_EQ(0xFFFFFFFF, val.truncOrSelf(64));
}
-TEST(APIntTest, concatMSB) {
+TEST(APIntTest, concat) {
APInt Int1(4, 0x1ULL);
APInt Int3(4, 0x3ULL);
@@ -2597,6 +2601,11 @@ TEST(APIntTest, concatMSB) {
APInt I64(64, 0x3ULL);
EXPECT_EQ(I64, I64.concat(I64).lshr(64).trunc(64));
+
+ APInt I65(65, 0x3ULL);
+ APInt I0 = APInt::getZeroWidth();
+ EXPECT_EQ(I65, I65.concat(I0));
+ EXPECT_EQ(I65, I0.concat(I65));
}
TEST(APIntTest, multiply) {