diff options
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 4 | ||||
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 10 |
2 files changed, 6 insertions, 8 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 402422507a5..56d5777288e 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -1937,8 +1937,8 @@ inline bool isShiftedMask(const APInt &APIVal) { /// This function returns the greatest common divisor of the two APInt values /// using Euclid's algorithm. /// -/// \returns the greatest common divisor of Val1 and Val2 -APInt GreatestCommonDivisor(const APInt &Val1, const APInt &Val2); +/// \returns the greatest common divisor of \param A and \param B. +APInt GreatestCommonDivisor(APInt A, APInt B); /// \brief Converts the given APInt to a double value. /// diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index d6139504f9a..0d4255da7f0 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -876,13 +876,11 @@ APInt APInt::reverseBits() const { return Reversed; } -APInt llvm::APIntOps::GreatestCommonDivisor(const APInt& API1, - const APInt& API2) { - APInt A = API1, B = API2; +APInt llvm::APIntOps::GreatestCommonDivisor(APInt A, APInt B) { while (!!B) { - APInt T = B; - B = A.urem(B); - A = T; + APInt R = A.urem(B); + A = std::move(B); + B = std::move(R); } return A; } |