]> granicus.if.org Git - llvm/commitdiff
[APInt] Remove an unneeded extra temporary APInt from toString.
authorCraig Topper <craig.topper@gmail.com>
Thu, 11 May 2017 07:10:43 +0000 (07:10 +0000)
committerCraig Topper <craig.topper@gmail.com>
Thu, 11 May 2017 07:10:43 +0000 (07:10 +0000)
Turns out udivrem can write its output to the same location as one of its inputs so the extra temporary isn't needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302772 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index d000ae82e0746c77cd03ea320aee40548b121544..6b01c9bb2776f2e05bf75b9e938ea01a4c3a7738 100644 (file)
@@ -1953,15 +1953,11 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
   } else {
     APInt divisor(Tmp.getBitWidth(), Radix);
     APInt APdigit;
-    APInt tmp2(Tmp.getBitWidth(), 0);
     while (Tmp.getBoolValue()) {
-      udivrem(Tmp, divisor, tmp2, APdigit);
+      udivrem(Tmp, divisor, Tmp, APdigit);
       unsigned Digit = (unsigned)APdigit.getZExtValue();
       assert(Digit < Radix && "divide failed");
       Str.push_back(Digits[Digit]);
-      // Move the quotient into Tmp and move the old allocation of Tmp into
-      // tmp2 to be used on the next loop iteration.
-      std::swap(Tmp, tmp2);
     }
   }