diff options
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index d43e1a817c9..361fc97c2ec 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -1686,8 +1686,11 @@ void APInt::udivrem(const APInt &LHS, const APInt &RHS, // There is only one word to consider so use the native versions. uint64_t lhsValue = LHS.U.pVal[0]; uint64_t rhsValue = RHS.U.pVal[0]; - Quotient = APInt(LHS.getBitWidth(), lhsValue / rhsValue); - Remainder = APInt(LHS.getBitWidth(), lhsValue % rhsValue); + // Make sure there is enough space to hold the results. + Quotient.reallocate(LHS.BitWidth); + Remainder.reallocate(LHS.BitWidth); + Quotient = lhsValue / rhsValue; + Remainder = lhsValue % rhsValue; return; } |