aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/APInt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/APInt.cpp')
-rw-r--r--lib/Support/APInt.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 08ec236200..0d0f9ffca4 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -43,7 +43,8 @@ inline static uint64_t* getMemory(uint32_t numWords) {
return result;
}
-APInt::APInt(uint32_t numBits, uint64_t val) : BitWidth(numBits), VAL(0) {
+APInt::APInt(uint32_t numBits, uint64_t val, bool isSigned )
+ : BitWidth(numBits), VAL(0) {
assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small");
assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large");
if (isSingleWord())
@@ -51,6 +52,9 @@ APInt::APInt(uint32_t numBits, uint64_t val) : BitWidth(numBits), VAL(0) {
else {
pVal = getClearedMemory(getNumWords());
pVal[0] = val;
+ if (isSigned && int64_t(val) < 0)
+ for (unsigned i = 1; i < getNumWords(); ++i)
+ pVal[i] = -1ULL;
}
clearUnusedBits();
}