OSDN Git Service

[APInt] Remove an APInt copy from the return of APInt::multiplicativeInverse.
authorCraig Topper <craig.topper@gmail.com>
Thu, 11 May 2017 18:40:53 +0000 (18:40 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 11 May 2017 18:40:53 +0000 (18:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302816 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index 0fade28..bcec648 100644 (file)
@@ -1141,7 +1141,10 @@ APInt APInt::multiplicativeInverse(const APInt& modulo) const {
   // interested in a positive inverse. Calculate a positive one from a negative
   // one if necessary. A simple addition of the modulo suffices because
   // abs(t[i]) is known to be less than *this/2 (see the link above).
-  return t[i].isNegative() ? t[i] + modulo : t[i];
+  if (t[i].isNegative())
+    t[i] += modulo;
+
+  return std::move(t[i]);
 }
 
 /// Calculate the magic numbers required to implement a signed integer division