[llvm] b85395f - [NFC][APInt] Refactor getMinSignedBits() in terms of getNumSignBits()

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 11:38:03 PDT 2020


Author: Roman Lebedev
Date: 2020-09-22T21:37:29+03:00
New Revision: b85395f309890bac5f2d3296ce08dc46c24ef77f

URL: https://github.com/llvm/llvm-project/commit/b85395f309890bac5f2d3296ce08dc46c24ef77f
DIFF: https://github.com/llvm/llvm-project/commit/b85395f309890bac5f2d3296ce08dc46c24ef77f.diff

LOG: [NFC][APInt] Refactor getMinSignedBits() in terms of getNumSignBits()

This is fully identical to the old implementation, just easier to read.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/APInt.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index fdc0850d21eb..f5860f6c7517 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1615,11 +1615,7 @@ class LLVM_NODISCARD APInt {
   /// returns the smallest bit width that will retain the negative value. For
   /// example, -1 can be written as 0b1 or 0xFFFFFFFFFF. 0b1 is shorter and so
   /// for -1, this function will always return 1.
-  unsigned getMinSignedBits() const {
-    if (isNegative())
-      return BitWidth - countLeadingOnes() + 1;
-    return getActiveBits() + 1;
-  }
+  unsigned getMinSignedBits() const { return BitWidth - getNumSignBits() + 1; }
 
   /// Get zero extended value
   ///


        


More information about the llvm-commits mailing list