[APInt] Remove support for wrapping from APInt::setBits.

This features isn't used anywhere in tree. It's existence seems to be preventing selfhost builds from inlining any of the setBits methods including setLowBits, setHighBits, and setBitsFrom. This is because the code makes the method recursive.

If anyone needs this feature in the future we could consider adding a setBitsWithWrap method. This way only the calls that need it would pay for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2017-04-30 07:45:01 +00:00
parent c07d5e69ae
commit f300b51fae
2 changed files with 15 additions and 19 deletions

View File

@ -1360,13 +1360,9 @@ public:
void setBits(unsigned loBit, unsigned hiBit) {
assert(hiBit <= BitWidth && "hiBit out of range");
assert(loBit <= BitWidth && "loBit out of range");
assert(loBit <= hiBit && "loBit greater than hiBit");
if (loBit == hiBit)
return;
if (loBit > hiBit) {
setLowBits(hiBit);
setHighBits(BitWidth - loBit);
return;
}
if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
uint64_t mask = WORD_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
mask <<= loBit;

View File

@ -1723,21 +1723,21 @@ TEST(APIntTest, getLowBitsSet) {
}
TEST(APIntTest, getBitsSet) {
APInt i64hi1lo1 = APInt::getBitsSet(64, 63, 1);
EXPECT_EQ(1u, i64hi1lo1.countLeadingOnes());
EXPECT_EQ(0u, i64hi1lo1.countLeadingZeros());
EXPECT_EQ(64u, i64hi1lo1.getActiveBits());
EXPECT_EQ(0u, i64hi1lo1.countTrailingZeros());
EXPECT_EQ(1u, i64hi1lo1.countTrailingOnes());
EXPECT_EQ(2u, i64hi1lo1.countPopulation());
APInt i64hi1lo1 = APInt::getBitsSet(64, 1, 63);
EXPECT_EQ(0u, i64hi1lo1.countLeadingOnes());
EXPECT_EQ(1u, i64hi1lo1.countLeadingZeros());
EXPECT_EQ(63u, i64hi1lo1.getActiveBits());
EXPECT_EQ(1u, i64hi1lo1.countTrailingZeros());
EXPECT_EQ(0u, i64hi1lo1.countTrailingOnes());
EXPECT_EQ(62u, i64hi1lo1.countPopulation());
APInt i127hi1lo1 = APInt::getBitsSet(127, 126, 1);
EXPECT_EQ(1u, i127hi1lo1.countLeadingOnes());
EXPECT_EQ(0u, i127hi1lo1.countLeadingZeros());
EXPECT_EQ(127u, i127hi1lo1.getActiveBits());
EXPECT_EQ(0u, i127hi1lo1.countTrailingZeros());
EXPECT_EQ(1u, i127hi1lo1.countTrailingOnes());
EXPECT_EQ(2u, i127hi1lo1.countPopulation());
APInt i127hi1lo1 = APInt::getBitsSet(127, 1, 126);
EXPECT_EQ(0u, i127hi1lo1.countLeadingOnes());
EXPECT_EQ(1u, i127hi1lo1.countLeadingZeros());
EXPECT_EQ(126u, i127hi1lo1.getActiveBits());
EXPECT_EQ(1u, i127hi1lo1.countTrailingZeros());
EXPECT_EQ(0u, i127hi1lo1.countTrailingOnes());
EXPECT_EQ(125u, i127hi1lo1.countPopulation());
}
TEST(APIntTest, getHighBitsSet) {