diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index a35b116b42e..d7933fc5a38 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -693,7 +693,7 @@ uint32_t APInt::getBitsNeeded(const char* str, uint32_t slen, uint8_t radix) { APInt tmp(sufficient, str, slen, radix); // Compute how many bits are required. - return isNegative + tmp.logBase2(); + return isNegative + tmp.logBase2() + 1; } uint64_t APInt::getHashValue() const {