]> granicus.if.org Git - llvm/commitdiff
[APInt] Use getActiveBits() to implement logBase2 and ceilLogBase2. NFC
authorCraig Topper <craig.topper@intel.com>
Wed, 20 Sep 2017 18:49:31 +0000 (18:49 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 20 Sep 2017 18:49:31 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313793 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h

index a1cce6e5fe170dba9d194e5cf3f32d0b4147cb1f..c81363cc16b7dba34195f06990fca9f94c3ce172 100644 (file)
@@ -1724,13 +1724,13 @@ public:
   /// @{
 
   /// \returns the floor log base 2 of this APInt.
-  unsigned logBase2() const { return BitWidth - 1 - countLeadingZeros(); }
+  unsigned logBase2() const { return getActiveBits() -  1; }
 
   /// \returns the ceil log base 2 of this APInt.
   unsigned ceilLogBase2() const {
     APInt temp(*this);
     --temp;
-    return BitWidth - temp.countLeadingZeros();
+    return temp.getActiveBits();
   }
 
   /// \returns the nearest log base 2 of this APInt. Ties round up.