Index: include/llvm/ADT/APInt.h =================================================================== --- include/llvm/ADT/APInt.h +++ include/llvm/ADT/APInt.h @@ -240,11 +240,11 @@ 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[]. Index: lib/Support/APInt.cpp =================================================================== --- lib/Support/APInt.cpp +++ lib/Support/APInt.cpp @@ -81,6 +81,7 @@ if (isSigned && int64_t(val) < 0) for (unsigned i = 1; i < getNumWords(); ++i) pVal[i] = -1ULL; + clearUnusedBits(); } void APInt::initSlowCase(const APInt& that) {