-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[APInt] Added APInt::clearBits() method #137098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-llvm-support Author: Liam Semeria (liamsemeria) ChangesAdded APInt::clearBits(unsigned loBit, unsigned hiBit) that clears bits within a certain range. Full diff: https://github.com/llvm/llvm-project/pull/137098.diff 3 Files Affected:
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 02d58d8c3d31c..c724411261388 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1413,6 +1413,26 @@ class [[nodiscard]] APInt {
U.pVal[whichWord(BitPosition)] &= Mask;
}
+ /// Clear the bits from loBit (inclusive) to hiBit (exclusive) to 0.
+ /// This function handles case when \p loBit <= \p hiBit.
+ void clearBits(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 < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
+ uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
+ mask = ~(mask << loBit);
+ if (isSingleWord())
+ U.VAL &= mask;
+ else
+ U.pVal[0] &= mask;
+ } else {
+ clearBitsSlowCase(loBit, hiBit);
+ }
+ }
+
/// Set bottom loBits bits to 0.
void clearLowBits(unsigned loBits) {
assert(loBits <= BitWidth && "More bits than bitwidth");
@@ -2051,6 +2071,9 @@ class [[nodiscard]] APInt {
/// out-of-line slow case for setBits.
void setBitsSlowCase(unsigned loBit, unsigned hiBit);
+ /// out-of-line slow case for clearBits.
+ void clearBitsSlowCase(unsigned loBit, unsigned hiBit);
+
/// out-of-line slow case for flipAllBits.
void flipAllBitsSlowCase();
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 4e45416b4598f..da7f223d48956 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -336,6 +336,33 @@ void APInt::setBitsSlowCase(unsigned loBit, unsigned hiBit) {
U.pVal[word] = WORDTYPE_MAX;
}
+void APInt::clearBitsSlowCase(unsigned loBit, unsigned hiBit) {
+ unsigned loWord = whichWord(loBit);
+ unsigned hiWord = whichWord(hiBit);
+
+ // Create an initial mask for the low word with ones below loBit.
+ uint64_t loMask = ~(WORDTYPE_MAX << whichBit(loBit));
+
+ // If hiBit is not aligned, we need a high mask.
+ unsigned hiShiftAmt = whichBit(hiBit);
+ if (hiShiftAmt != 0) {
+ // Create a high mask with ones above hiBit.
+ uint64_t hiMask = ~(WORDTYPE_MAX >> (APINT_BITS_PER_WORD - hiShiftAmt));
+ // If loWord and hiWord are equal, then we combine the masks. Otherwise,
+ // set the bits in hiWord.
+ if (hiWord == loWord)
+ loMask &= hiMask;
+ else
+ U.pVal[hiWord] &= hiMask;
+ }
+ // Apply the mask to the low word.
+ U.pVal[loWord] &= loMask;
+
+ // Fill any words between loWord and hiWord with all zeros.
+ for (unsigned word = loWord + 1; word < hiWord; ++word)
+ U.pVal[word] = 0;
+}
+
// Complement a bignum in-place.
static void tcComplement(APInt::WordType *dst, unsigned parts) {
for (unsigned i = 0; i < parts; i++)
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index b14366eac2185..d4411dfe36cc9 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2520,6 +2520,62 @@ TEST(APIntTest, setAllBits) {
EXPECT_EQ(128u, i128.popcount());
}
+TEST(APIntTest, clearBits) {
+ APInt i32 = APInt::getAllOnes(32);
+ i32.clearBits(1, 3);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(29u, i32.countl_one());
+ EXPECT_EQ(30u, i32.popcount());
+
+ i32.clearBits(15, 15);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(29u, i32.countl_one());
+ EXPECT_EQ(30u, i32.popcount());
+
+ i32.clearBits(28, 31);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(1u, i32.countl_one());
+ EXPECT_EQ(27u, i32.popcount());
+ EXPECT_EQ(static_cast<uint64_t>((1 << 31) | ((~0u >> 4) & (~0u << 3)) | 1),
+ i32.getZExtValue());
+
+ APInt i256 = APInt::getAllOnes(256);
+ i256.clearBits(10, 250);
+ EXPECT_EQ(10u, i256.countr_one());
+ EXPECT_EQ(0u, i256.countr_zero());
+ EXPECT_EQ(256u, i256.getActiveBits());
+ EXPECT_EQ(0u, i256.countl_zero());
+ EXPECT_EQ(6u, i256.countl_one());
+ EXPECT_EQ(16u, i256.popcount());
+
+ APInt i64hi32 = APInt::getAllOnes(64);
+ i64hi32.clearBits(0, 32);
+ EXPECT_EQ(32u, i64hi32.countl_one());
+ EXPECT_EQ(0u, i64hi32.countl_zero());
+ EXPECT_EQ(64u, i64hi32.getActiveBits());
+ EXPECT_EQ(32u, i64hi32.countr_zero());
+ EXPECT_EQ(0u, i64hi32.countr_one());
+ EXPECT_EQ(32u, i64hi32.popcount());
+
+ i64hi32 = APInt::getAllOnes(64);
+ i64hi32.clearBits(32, 64);
+ EXPECT_EQ(32u, i64hi32.countr_one());
+ EXPECT_EQ(0u, i64hi32.countr_zero());
+ EXPECT_EQ(32u, i64hi32.getActiveBits());
+ EXPECT_EQ(32u, i64hi32.countl_zero());
+ EXPECT_EQ(0u, i64hi32.countl_one());
+ EXPECT_EQ(32u, i64hi32.popcount());
+}
+
TEST(APIntTest, getLoBits) {
APInt i32(32, 0xfa);
i32.setHighBits(1);
|
@llvm/pr-subscribers-llvm-adt Author: Liam Semeria (liamsemeria) ChangesAdded APInt::clearBits(unsigned loBit, unsigned hiBit) that clears bits within a certain range. Full diff: https://github.com/llvm/llvm-project/pull/137098.diff 3 Files Affected:
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 02d58d8c3d31c..c724411261388 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1413,6 +1413,26 @@ class [[nodiscard]] APInt {
U.pVal[whichWord(BitPosition)] &= Mask;
}
+ /// Clear the bits from loBit (inclusive) to hiBit (exclusive) to 0.
+ /// This function handles case when \p loBit <= \p hiBit.
+ void clearBits(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 < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) {
+ uint64_t mask = WORDTYPE_MAX >> (APINT_BITS_PER_WORD - (hiBit - loBit));
+ mask = ~(mask << loBit);
+ if (isSingleWord())
+ U.VAL &= mask;
+ else
+ U.pVal[0] &= mask;
+ } else {
+ clearBitsSlowCase(loBit, hiBit);
+ }
+ }
+
/// Set bottom loBits bits to 0.
void clearLowBits(unsigned loBits) {
assert(loBits <= BitWidth && "More bits than bitwidth");
@@ -2051,6 +2071,9 @@ class [[nodiscard]] APInt {
/// out-of-line slow case for setBits.
void setBitsSlowCase(unsigned loBit, unsigned hiBit);
+ /// out-of-line slow case for clearBits.
+ void clearBitsSlowCase(unsigned loBit, unsigned hiBit);
+
/// out-of-line slow case for flipAllBits.
void flipAllBitsSlowCase();
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 4e45416b4598f..da7f223d48956 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -336,6 +336,33 @@ void APInt::setBitsSlowCase(unsigned loBit, unsigned hiBit) {
U.pVal[word] = WORDTYPE_MAX;
}
+void APInt::clearBitsSlowCase(unsigned loBit, unsigned hiBit) {
+ unsigned loWord = whichWord(loBit);
+ unsigned hiWord = whichWord(hiBit);
+
+ // Create an initial mask for the low word with ones below loBit.
+ uint64_t loMask = ~(WORDTYPE_MAX << whichBit(loBit));
+
+ // If hiBit is not aligned, we need a high mask.
+ unsigned hiShiftAmt = whichBit(hiBit);
+ if (hiShiftAmt != 0) {
+ // Create a high mask with ones above hiBit.
+ uint64_t hiMask = ~(WORDTYPE_MAX >> (APINT_BITS_PER_WORD - hiShiftAmt));
+ // If loWord and hiWord are equal, then we combine the masks. Otherwise,
+ // set the bits in hiWord.
+ if (hiWord == loWord)
+ loMask &= hiMask;
+ else
+ U.pVal[hiWord] &= hiMask;
+ }
+ // Apply the mask to the low word.
+ U.pVal[loWord] &= loMask;
+
+ // Fill any words between loWord and hiWord with all zeros.
+ for (unsigned word = loWord + 1; word < hiWord; ++word)
+ U.pVal[word] = 0;
+}
+
// Complement a bignum in-place.
static void tcComplement(APInt::WordType *dst, unsigned parts) {
for (unsigned i = 0; i < parts; i++)
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index b14366eac2185..d4411dfe36cc9 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2520,6 +2520,62 @@ TEST(APIntTest, setAllBits) {
EXPECT_EQ(128u, i128.popcount());
}
+TEST(APIntTest, clearBits) {
+ APInt i32 = APInt::getAllOnes(32);
+ i32.clearBits(1, 3);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(29u, i32.countl_one());
+ EXPECT_EQ(30u, i32.popcount());
+
+ i32.clearBits(15, 15);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(29u, i32.countl_one());
+ EXPECT_EQ(30u, i32.popcount());
+
+ i32.clearBits(28, 31);
+ EXPECT_EQ(1u, i32.countr_one());
+ EXPECT_EQ(0u, i32.countr_zero());
+ EXPECT_EQ(32u, i32.getActiveBits());
+ EXPECT_EQ(0u, i32.countl_zero());
+ EXPECT_EQ(1u, i32.countl_one());
+ EXPECT_EQ(27u, i32.popcount());
+ EXPECT_EQ(static_cast<uint64_t>((1 << 31) | ((~0u >> 4) & (~0u << 3)) | 1),
+ i32.getZExtValue());
+
+ APInt i256 = APInt::getAllOnes(256);
+ i256.clearBits(10, 250);
+ EXPECT_EQ(10u, i256.countr_one());
+ EXPECT_EQ(0u, i256.countr_zero());
+ EXPECT_EQ(256u, i256.getActiveBits());
+ EXPECT_EQ(0u, i256.countl_zero());
+ EXPECT_EQ(6u, i256.countl_one());
+ EXPECT_EQ(16u, i256.popcount());
+
+ APInt i64hi32 = APInt::getAllOnes(64);
+ i64hi32.clearBits(0, 32);
+ EXPECT_EQ(32u, i64hi32.countl_one());
+ EXPECT_EQ(0u, i64hi32.countl_zero());
+ EXPECT_EQ(64u, i64hi32.getActiveBits());
+ EXPECT_EQ(32u, i64hi32.countr_zero());
+ EXPECT_EQ(0u, i64hi32.countr_one());
+ EXPECT_EQ(32u, i64hi32.popcount());
+
+ i64hi32 = APInt::getAllOnes(64);
+ i64hi32.clearBits(32, 64);
+ EXPECT_EQ(32u, i64hi32.countr_one());
+ EXPECT_EQ(0u, i64hi32.countr_zero());
+ EXPECT_EQ(32u, i64hi32.getActiveBits());
+ EXPECT_EQ(32u, i64hi32.countl_zero());
+ EXPECT_EQ(0u, i64hi32.countl_one());
+ EXPECT_EQ(32u, i64hi32.popcount());
+}
+
TEST(APIntTest, getLoBits) {
APInt i32(32, 0xfa);
i32.setHighBits(1);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Please can you search for "DemandedSrcElts.insertBits(APInt::getZero(NumSubElts), Idx);" and replace that INSERT_SUBVECTOR demanded elts handling with clearBits?
EXPECT_EQ(static_cast<uint64_t>((1 << 31) | ((~0u >> 4) & (~0u << 3)) | 1), | ||
i32.getZExtValue()); | ||
|
||
APInt i256 = APInt::getAllOnes(256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you add an additional case of > 64 bits that isn't a multiple of 64 bits (e.g. APInt::getAllOnes(311))? This will test clearBitsSlowCase more thoroughly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll add that test case.
@@ -2520,6 +2520,62 @@ TEST(APIntTest, setAllBits) { | |||
EXPECT_EQ(128u, i128.popcount()); | |||
} | |||
|
|||
TEST(APIntTest, clearBits) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: tests might be shorter and clearer with the string‑based APInt
ctor:
APInt hi = APInt::getAllOnes(64);
hi.clearBits(0, 32);
EXPECT_EQ(APInt(64, "FFFFFFFF00000000", 16), hi);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats very helpful thanks for the tip!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers!
llvm/include/llvm/ADT/APInt.h
Outdated
/// This function handles case when \p loBit <= \p hiBit. | ||
void clearBits(unsigned loBit, unsigned hiBit) { | ||
assert(hiBit <= BitWidth && "hiBit out of range"); | ||
assert(loBit <= BitWidth && "loBit out of range"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this assert. It's implied by the other two.
llvm/include/llvm/ADT/APInt.h
Outdated
assert(loBit <= hiBit && "loBit greater than hiBit"); | ||
if (loBit == hiBit) | ||
return; | ||
if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify this to:
if (loBit < APINT_BITS_PER_WORD && hiBit <= APINT_BITS_PER_WORD) { | |
if (hiBit <= APINT_BITS_PER_WORD) { |
llvm/include/llvm/ADT/APInt.h
Outdated
@@ -1413,6 +1413,26 @@ class [[nodiscard]] APInt { | |||
U.pVal[whichWord(BitPosition)] &= Mask; | |||
} | |||
|
|||
/// Clear the bits from loBit (inclusive) to hiBit (exclusive) to 0. | |||
/// This function handles case when \p loBit <= \p hiBit. | |||
void clearBits(unsigned loBit, unsigned hiBit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable and parameter names should start with a capital letter. Same for mask
below.
@jayfoad Its likely that APInt::setBits already suffers from the same issues as this is mainly a copy of that |
I wanted to keep it similar to setBits but I can make those changes to clearBits and setBits should I do that? |
If you're willing, I'd recommend doing a separate cleanup PR to fix the setBits equivalent issues that @jayfoad identified first, then merge the changes (after they're accepted) into this clearBits patch - make sense? |
Yeah that makes sense. That would just be changes to setBits and not to the unit tests right? |
…etBits (#138038) During [pull request](llvm/llvm-project#137098) it was suggested that I remove these redundant parts of APInt::SetBits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update to match your APInt::setBits changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to fix the style issue of variables/parameters starting with capital letter
thats an issue across the entire file. Do you want me to just do that for clearBits? |
Yes, just any new code. Avoids excess churn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A final couple of trivial minors - @jayfoad any more comments?
llvm/include/llvm/ADT/APInt.h
Outdated
/// Clear the bits from loBit (inclusive) to hiBit (exclusive) to 0. | ||
/// This function handles case when \p loBit <= \p hiBit. | ||
void clearBits(unsigned LoBit, unsigned HiBit) { | ||
assert(HiBit <= BitWidth && "hiBit out of range"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HiBit out of range
llvm/include/llvm/ADT/APInt.h
Outdated
/// This function handles case when \p loBit <= \p hiBit. | ||
void clearBits(unsigned LoBit, unsigned HiBit) { | ||
assert(HiBit <= BitWidth && "hiBit out of range"); | ||
assert(LoBit <= HiBit && "loBit greater than hiBit"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoBit greater than HiBit
llvm/include/llvm/ADT/APInt.h
Outdated
@@ -2051,6 +2070,9 @@ class [[nodiscard]] APInt { | |||
/// out-of-line slow case for setBits. | |||
void setBitsSlowCase(unsigned loBit, unsigned hiBit); | |||
|
|||
/// out-of-line slow case for clearBits. | |||
void clearBitsSlowCase(unsigned loBit, unsigned hiBit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoBit
+ HiBit
llvm/include/llvm/ADT/APInt.h
Outdated
/// Clear the bits from loBit (inclusive) to hiBit (exclusive) to 0. | ||
/// This function handles case when \p loBit <= \p hiBit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix argument names in this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@liamsemeria Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
// If LoWord and HiWord are equal, then we combine the masks. Otherwise, | ||
// set the bits in HiWord. | ||
if (HiWord == LoWord) | ||
LoMask &= HiMask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liamsemeria should this be LoMask |= HiMask
? Noticed when triaging #141098
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional unit test (clear bits in same word) that fails without the fix:
APInt i299 = APInt::getAllOnes(299);
i299.clearBits(240, 250);
EXPECT_EQ(240u, i299.countr_one());
EXPECT_EQ(0u, i299.countr_zero());
EXPECT_EQ(299u, i299.getActiveBits());
EXPECT_EQ(0u, i299.countl_zero());
EXPECT_EQ(49u, i299.countl_one());
EXPECT_EQ(289u, i299.popcount());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it should be LoMask |= HiMask
. I've confirmed it fixes the failure on qemu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll clean up my tests and put up a PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added APInt::clearBits(unsigned loBit, unsigned hiBit) that clears bits within a certain range. Fixes llvm#136550 --------- Co-authored-by: Simon Pilgrim <[email protected]>
Added APInt::clearBits(unsigned loBit, unsigned hiBit) that clears bits within a certain range.
Fixes #136550