diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-03-27 17:10:21 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-03-27 17:10:21 +0000 |
| commit | afc9e3534371e07010752db09063669842763705 (patch) | |
| tree | 8dfed373473f35d9126368bf195e635c44f88985 | |
| parent | f70f6836709208c4ab726abccd84a3eca0ecd0e9 (diff) | |
| download | bcm5719-llvm-afc9e3534371e07010752db09063669842763705.tar.gz bcm5719-llvm-afc9e3534371e07010752db09063669842763705.zip | |
[APInt] Move the >64 bit case for flipAllBits out of line.
This is more consistent with what we do for other operations. This shrinks the opt binary on my build by ~72k.
llvm-svn: 298858
| -rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 12 | ||||
| -rw-r--r-- | llvm/lib/Support/APInt.cpp | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 27e164c6641..c407d9c55a2 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -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. diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 58fa2f53690..aacb7440313 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -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". |

