diff options
author | Craig Topper <craig.topper@intel.com> | 2017-07-07 19:56:18 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-07-07 19:56:18 +0000 |
commit | 8614bf0c87bb59fd0799873cd427f53079f121bb (patch) | |
tree | d1ece6eb72af2f2327243155496db3ecc73e5e44 | |
parent | 16c930ae14e3452fd864224c5f61226372252f4b (diff) |
[APInt] Add a fastpath for the single word case of isOneValue to match isNullValue, isAllOnesValue, etc. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307430 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/APInt.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index e5f0c35534a..a1cce6e5fe1 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -401,7 +401,11 @@ public: /// \brief Determine if this is a value of 1. /// /// This checks to see if the value of this APInt is one. - bool isOneValue() const { return getActiveBits() == 1; } + bool isOneValue() const { + if (isSingleWord()) + return U.VAL == 1; + return countLeadingZerosSlowCase() == BitWidth - 1; + } /// \brief Determine if this is the largest unsigned value. /// |