summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ADT/APInt.h7
-rw-r--r--llvm/lib/Support/APInt.cpp1
2 files changed, 5 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 2af3aabe188..2acb60f769d 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -240,11 +240,12 @@ public:
APInt(unsigned numBits, uint64_t val, bool isSigned = false)
: BitWidth(numBits), VAL(0) {
assert(BitWidth && "bitwidth too small");
- if (isSingleWord())
+ if (isSingleWord()) {
VAL = val;
- else
+ clearUnusedBits();
+ } else {
initSlowCase(val, isSigned);
- clearUnusedBits();
+ }
}
/// \brief Construct an APInt of numBits width, initialized as bigVal[].
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 10124fabaec..836498e6c0e 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -81,6 +81,7 @@ void APInt::initSlowCase(uint64_t val, bool isSigned) {
if (isSigned && int64_t(val) < 0)
for (unsigned i = 1; i < getNumWords(); ++i)
pVal[i] = -1ULL;
+ clearUnusedBits();
}
void APInt::initSlowCase(const APInt& that) {
OpenPOWER on IntegriCloud