From 9082d1200011b967ff86e7056efa229598d8bb7f Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 7 Jun 2017 00:57:57 +0000 Subject: [PATCH] [APInt] Add a isOneValue method that can determine if a number is 1 by only using getActiveBits/countLeadingZeros Previously you would have to use operator==(uint64_t) which does the getActiveBits call and a uint64_t comparison. But we can get all we need to know from the getActiveBits call. This method will be used in another commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304854 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/APInt.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index fe75e25bd8d..b45f0601b0a 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -392,6 +392,12 @@ public: /// not. bool isNullValue() const { return !*this; } + /// \brief Determine if all bits are clear + /// + /// This checks to see if the value has all bits of the APInt are clear or + /// not. + bool isOneValue() const { return getActiveBits() == 1; } + /// \brief Determine if this is the largest unsigned value. /// /// This checks to see if the value of this APInt is the maximum unsigned -- 2.50.1