Skip to content

Commit 7f7d120

Browse files
committedApr 30, 2017
[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. llvm-svn: 301769
1 parent 778f57b commit 7f7d120

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed
 

‎llvm/include/llvm/ADT/APInt.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -1360,13 +1360,9 @@ class LLVM_NODISCARD APInt {
13601360
void setBits(unsigned loBit, unsigned hiBit) {
13611361
assert(hiBit <= BitWidth && "hiBit out of range");
13621362
assert(loBit <= BitWidth && "loBit out of range");
1363+
assert(loBit <= hiBit && "loBit greater than hiBit");
13631364
if (loBit == hiBit)
13641365
return;
1365-
if (loBit > hiBit) {
1366-
setLowBits(hiBit);
1367-
setHighBits(BitWidth - loBit);
1368-
return;
1369-
}
13701366
if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
13711367
uint64_t mask = WORD_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
13721368
mask <<= loBit;

‎llvm/unittests/ADT/APIntTest.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -1723,21 +1723,21 @@ TEST(APIntTest, getLowBitsSet) {
17231723
}
17241724

17251725
TEST(APIntTest, getBitsSet) {
1726-
APInt i64hi1lo1 = APInt::getBitsSet(64, 63, 1);
1727-
EXPECT_EQ(1u, i64hi1lo1.countLeadingOnes());
1728-
EXPECT_EQ(0u, i64hi1lo1.countLeadingZeros());
1729-
EXPECT_EQ(64u, i64hi1lo1.getActiveBits());
1730-
EXPECT_EQ(0u, i64hi1lo1.countTrailingZeros());
1731-
EXPECT_EQ(1u, i64hi1lo1.countTrailingOnes());
1732-
EXPECT_EQ(2u, i64hi1lo1.countPopulation());
1733-
1734-
APInt i127hi1lo1 = APInt::getBitsSet(127, 126, 1);
1735-
EXPECT_EQ(1u, i127hi1lo1.countLeadingOnes());
1736-
EXPECT_EQ(0u, i127hi1lo1.countLeadingZeros());
1737-
EXPECT_EQ(127u, i127hi1lo1.getActiveBits());
1738-
EXPECT_EQ(0u, i127hi1lo1.countTrailingZeros());
1739-
EXPECT_EQ(1u, i127hi1lo1.countTrailingOnes());
1740-
EXPECT_EQ(2u, i127hi1lo1.countPopulation());
1726+
APInt i64hi1lo1 = APInt::getBitsSet(64, 1, 63);
1727+
EXPECT_EQ(0u, i64hi1lo1.countLeadingOnes());
1728+
EXPECT_EQ(1u, i64hi1lo1.countLeadingZeros());
1729+
EXPECT_EQ(63u, i64hi1lo1.getActiveBits());
1730+
EXPECT_EQ(1u, i64hi1lo1.countTrailingZeros());
1731+
EXPECT_EQ(0u, i64hi1lo1.countTrailingOnes());
1732+
EXPECT_EQ(62u, i64hi1lo1.countPopulation());
1733+
1734+
APInt i127hi1lo1 = APInt::getBitsSet(127, 1, 126);
1735+
EXPECT_EQ(0u, i127hi1lo1.countLeadingOnes());
1736+
EXPECT_EQ(1u, i127hi1lo1.countLeadingZeros());
1737+
EXPECT_EQ(126u, i127hi1lo1.getActiveBits());
1738+
EXPECT_EQ(1u, i127hi1lo1.countTrailingZeros());
1739+
EXPECT_EQ(0u, i127hi1lo1.countTrailingOnes());
1740+
EXPECT_EQ(125u, i127hi1lo1.countPopulation());
17411741
}
17421742

17431743
TEST(APIntTest, getHighBitsSet) {

0 commit comments

Comments
 (0)
Please sign in to comment.