[llvm] r302816 - [APInt] Remove an APInt copy from the return of APInt::multiplicativeInverse.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 11:40:54 PDT 2017
Author: ctopper
Date: Thu May 11 13:40:53 2017
New Revision: 302816
URL: http://llvm.org/viewvc/llvm-project?rev=302816&view=rev
Log:
[APInt] Remove an APInt copy from the return of APInt::multiplicativeInverse.
Modified:
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=302816&r1=302815&r2=302816&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Thu May 11 13:40:53 2017
@@ -1141,7 +1141,10 @@ APInt APInt::multiplicativeInverse(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
More information about the llvm-commits
mailing list