From 63f417ef39963afa9722a7b3c5cf3b28a9d41883 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Tue, 30 Nov 2021 00:47:08 -0500 Subject: [ADT] Remove 0-width Asserts in APInt.getZExtValue Remove assertion that disallows getting a zero-extended value from a zero-width APInt. This check is too restrictive and makes it difficult to use APInt to model zero-width things, e.g., zero-width wires in the CIRCT project. Signed-off-by: Schuyler Eldridge Reviewed By: lattner, darthscsi, nikic Differential Revision: https://reviews.llvm.org/D114768 --- llvm/unittests/ADT/APIntTest.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/unittests/ADT/APIntTest.cpp') diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index 8a731633..95cb213 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -3054,6 +3054,9 @@ TEST(APIntTest, ZeroWidth) { EXPECT_EQ(0U, APInt(4, 3).trunc(0).getBitWidth()); EXPECT_TRUE(ZW.isAllOnes()); + // Zero extension. + EXPECT_EQ(0U, ZW.getZExtValue()); + SmallString<42> STR; ZW.toStringUnsigned(STR); EXPECT_EQ("0", STR); -- cgit v1.1