[APInt] Remove special case for i1.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 4 Jun 2015 18:19:13 +0000 (18:19 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 4 Jun 2015 18:19:13 +0000 (18:19 +0000)
Add a unit test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239062 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h
unittests/ADT/APIntTest.cpp

index 36d8159d21ba08be1219911660033a66634264a6..e5d143d8ebe1362281b464586d775480b10a071c 100644 (file)
@@ -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.
index 498f50c9c81ff6ade7ecde40218431b266ae51a3..e4398f0f669c9243252c367e0c674911cb30fce7 100644 (file)
@@ -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);