[llvm] r302770 - [APInt] Use negate() instead of copying an APInt to negate it and then writing back over the original value.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 00:02:04 PDT 2017


Author: ctopper
Date: Thu May 11 02:02:04 2017
New Revision: 302770

URL: http://llvm.org/viewvc/llvm-project?rev=302770&view=rev
Log:
[APInt] Use negate() instead of copying an APInt to negate it and then writing back over the original value.

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=302770&r1=302769&r2=302770&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Thu May 11 02:02:04 2017
@@ -1710,12 +1710,12 @@ void APInt::sdivrem(const APInt &LHS, co
       APInt::udivrem(-LHS, -RHS, Quotient, Remainder);
     else {
       APInt::udivrem(-LHS, RHS, Quotient, Remainder);
-      Quotient = -Quotient;
+      Quotient.negate();
     }
-    Remainder = -Remainder;
+    Remainder.negate();
   } else if (RHS.isNegative()) {
     APInt::udivrem(LHS, -RHS, Quotient, Remainder);
-    Quotient = -Quotient;
+    Quotient.negate();
   } else {
     APInt::udivrem(LHS, RHS, Quotient, Remainder);
   }




More information about the llvm-commits mailing list