diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-04 18:19:13 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-06-04 18:19:13 +0000 |
| commit | 886461e271e99b959d93ef053cc0a3316b75ca20 (patch) | |
| tree | a27b997f454aff9f0300c806dc095e3085dd46ba | |
| parent | d5d93ecd038b4af761b7777b82d3a07551d8c1ff (diff) | |
| download | bcm5719-llvm-886461e271e99b959d93ef053cc0a3316b75ca20.tar.gz bcm5719-llvm-886461e271e99b959d93ef053cc0a3316b75ca20.zip | |
[APInt] Remove special case for i1.
Add a unit test.
llvm-svn: 239062
| -rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 5 | ||||
| -rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 36d8159d21b..e5d143d8ebe 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -351,8 +351,7 @@ public: /// This checks to see if the value of this APInt is the maximum signed /// value for the APInt's bit width. bool isMaxSignedValue() const { - return BitWidth == 1 ? VAL == 0 - : !isNegative() && countPopulation() == BitWidth - 1; + return !isNegative() && countPopulation() == BitWidth - 1; } /// \brief Determine if this is the smallest unsigned value. @@ -366,7 +365,7 @@ public: /// This checks to see if the value of this APInt is the minimum signed /// value for the APInt's bit width. bool isMinSignedValue() const { - return BitWidth == 1 ? VAL == 1 : isNegative() && isPowerOf2(); + return isNegative() && isPowerOf2(); } /// \brief Check if this APInt has an N-bits unsigned integer value. diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index 498f50c9c81..e4398f0f669 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -134,6 +134,12 @@ TEST(APIntTest, i1) { EXPECT_EQ(one, neg_one); EXPECT_EQ(two, neg_two); + // Min/max signed values. + EXPECT_TRUE(zero.isMaxSignedValue()); + EXPECT_FALSE(one.isMaxSignedValue()); + EXPECT_FALSE(zero.isMinSignedValue()); + EXPECT_TRUE(one.isMinSignedValue()); + // Additions. EXPECT_EQ(two, one + one); EXPECT_EQ(zero, neg_one + one); |

