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 | 45f53414ad273da35b1182e6de9b694a7ff52cf0 (patch) | |
tree | 7807dd8263602bb31850117f4c57210a570f2379 | |
parent | 4cea2ec254da462149839b3a48c1bfc4dc7e2d48 (diff) | |
download | bcm5719-llvm-45f53414ad273da35b1182e6de9b694a7ff52cf0.tar.gz bcm5719-llvm-45f53414ad273da35b1182e6de9b694a7ff52cf0.zip |
[APInt] Add a fastpath for the single word case of isOneValue to match isNullValue, isAllOnesValue, etc. NFCI
llvm-svn: 307430
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index e5f0c35534a..a1cce6e5fe1 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/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. /// |