[APInt] Use getActiveBits() to implement logBase2 and ceilLogBase2. NFC

llvm-svn: 313793
This commit is contained in:
Craig Topper 2017-09-20 18:49:31 +00:00
parent a0c897f634
commit be46b4e6d7
1 changed files with 2 additions and 2 deletions

View 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.