1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[APInt] Remove special case for i1.

Add a unit test.

llvm-svn: 239062
This commit is contained in:
Benjamin Kramer 2015-06-04 18:19:13 +00:00
parent b3a8428737
commit cc65db81cb
2 changed files with 8 additions and 3 deletions

View 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.

View 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);