]> granicus.if.org Git - llvm/commitdiff
[APInt] Move the >64 bit case for flipAllBits out of line.
authorCraig Topper <craig.topper@gmail.com>
Mon, 27 Mar 2017 17:10:21 +0000 (17:10 +0000)
committerCraig Topper <craig.topper@gmail.com>
Mon, 27 Mar 2017 17:10:21 +0000 (17:10 +0000)
This is more consistent with what we do for other operations. This shrinks the opt binary on my build by ~72k.

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

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

index 27e164c66416bc7f80d67600c8680335e99f7430..c407d9c55a285ae5d833a9540579b4b5806f26ef 100644 (file)
@@ -217,6 +217,9 @@ class LLVM_NODISCARD APInt {
   /// out-of-line slow case for setBits.
   void setBitsSlowCase(unsigned loBit, unsigned hiBit);
 
+  /// out-of-line slow case for flipAllBits.
+  void flipAllBitsSlowCase();
+
 public:
   /// \name Constructors
   /// @{
@@ -1233,13 +1236,12 @@ public:
 
   /// \brief Toggle every bit to its opposite value.
   void flipAllBits() {
-    if (isSingleWord())
+    if (isSingleWord()) {
       VAL ^= UINT64_MAX;
-    else {
-      for (unsigned i = 0; i < getNumWords(); ++i)
-        pVal[i] ^= UINT64_MAX;
+      clearUnusedBits();
+    } else {
+      flipAllBitsSlowCase();
     }
-    clearUnusedBits();
   }
 
   /// \brief Toggles a given bit to its opposite value.
index 58fa2f53690ac8b89bd730d2a1c77108f3634e96..aacb74403131f9520a0bc57090d22562fe806064 100644 (file)
@@ -581,6 +581,11 @@ void APInt::clearBit(unsigned bitPosition) {
 }
 
 /// @brief Toggle every bit to its opposite value.
+void APInt::flipAllBitsSlowCase() {
+  for (unsigned i = 0; i < getNumWords(); ++i)
+    pVal[i] ^= UINT64_MAX;
+  clearUnusedBits();
+}
 
 /// Toggle a given bit to its opposite value whose position is given
 /// as "bitPosition".