[llvm] [APInt] Added APInt::clearBits() method (PR #137098)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 06:21:44 PDT 2025


================
@@ -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");
----------------
jayfoad wrote:

Don't need this assert. It's implied by the other two.

https://github.com/llvm/llvm-project/pull/137098


More information about the llvm-commits mailing list