[llvm] r307430 - [APInt] Add a fastpath for the single word case of isOneValue to match isNullValue, isAllOnesValue, etc. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 12:56:18 PDT 2017
Author: ctopper
Date: Fri Jul 7 12:56:18 2017
New Revision: 307430
URL: http://llvm.org/viewvc/llvm-project?rev=307430&view=rev
Log:
[APInt] Add a fastpath for the single word case of isOneValue to match isNullValue, isAllOnesValue, etc. NFCI
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=307430&r1=307429&r2=307430&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Fri Jul 7 12:56:18 2017
@@ -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.
///
More information about the llvm-commits
mailing list