]> granicus.if.org Git - llvm/commitdiff
[APInt] Move operator&=(uint64_t) inline and use memset to clear the upper words.
authorCraig Topper <craig.topper@gmail.com>
Mon, 27 Mar 2017 18:16:17 +0000 (18:16 +0000)
committerCraig Topper <craig.topper@gmail.com>
Mon, 27 Mar 2017 18:16:17 +0000 (18:16 +0000)
This method is pretty new and probably isn't use much in the code base so this should have a negligible size impact. The OR and XOR operators are already inline.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298870 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h
lib/Support/APInt.cpp

index 220e408da15d9c8e3379857bcb54f5b9b828a6e0..a29cfe5fbca8981ad8dd558a4ec923fe343b61cd 100644 (file)
@@ -691,7 +691,15 @@ public:
   /// Performs a bitwise AND operation on this APInt and RHS. RHS is
   /// logically zero-extended or truncated to match the bit-width of
   /// the LHS.
-  APInt &operator&=(uint64_t RHS);
+  APInt &operator&=(uint64_t RHS) {
+    if (isSingleWord()) {
+      VAL &= RHS;
+      return *this;
+    }
+    pVal[0] &= RHS;
+    memset(pVal+1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
+    return *this;
+  }
 
   /// \brief Bitwise OR assignment operator.
   ///
index aacb74403131f9520a0bc57090d22562fe806064..ebcbb1518672005f938d112ddf4857ab26d08810 100644 (file)
@@ -428,18 +428,6 @@ APInt& APInt::operator&=(const APInt& RHS) {
   return *this;
 }
 
-APInt &APInt::operator&=(uint64_t RHS) {
-  if (isSingleWord()) {
-    VAL &= RHS;
-    return *this;
-  }
-  pVal[0] &= RHS;
-  unsigned numWords = getNumWords();
-  for (unsigned i = 1; i < numWords; ++i)
-    pVal[i] = 0;
-  return *this;
-}
-
 APInt& APInt::operator|=(const APInt& RHS) {
   assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
   if (isSingleWord()) {