Skip to content

Commit b85395f

Browse files
committed
[NFC][APInt] Refactor getMinSignedBits() in terms of getNumSignBits()
This is fully identical to the old implementation, just easier to read.
1 parent ba5afe5 commit b85395f

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

llvm/include/llvm/ADT/APInt.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,11 +1615,7 @@ class LLVM_NODISCARD APInt {
16151615
/// returns the smallest bit width that will retain the negative value. For
16161616
/// example, -1 can be written as 0b1 or 0xFFFFFFFFFF. 0b1 is shorter and so
16171617
/// for -1, this function will always return 1.
1618-
unsigned getMinSignedBits() const {
1619-
if (isNegative())
1620-
return BitWidth - countLeadingOnes() + 1;
1621-
return getActiveBits() + 1;
1622-
}
1618+
unsigned getMinSignedBits() const { return BitWidth - getNumSignBits() + 1; }
16231619

16241620
/// Get zero extended value
16251621
///

0 commit comments

Comments
 (0)