<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 11, 2017 at 12:02 AM Craig Topper via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Thu May 11 01:48:54 2017<br>
New Revision: 302769<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302769&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=302769&view=rev</a><br>
Log:<br>
[SCEV] Reduce possible APInt allocations a bit.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=302769&r1=302768&r2=302769&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=302769&r1=302768&r2=302769&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu May 11 01:48:54 2017<br>
@@ -7377,15 +7377,18 @@ SolveQuadraticEquation(const SCEVAddRecE<br>
   const APInt &N = NC->getAPInt();<br>
   APInt Two(BitWidth, 2);<br>
<br>
-  const APInt& C = L;<br>
   // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C<br>
-  // The B coefficient is M-N/2<br>
-  APInt B(M);<br>
-  B -= N.sdiv(Two);<br>
<br>
   // The A coefficient is N/2<br>
   APInt A(N.sdiv(Two));<br>
<br>
+  // The B coefficient is M-N/2<br>
+  APInt B(M);<br></blockquote><div><br>Prefer copy init over direct init:<br><br>  APInt B = M;<br><br>That way it's clear to the reader that no explicit (ie: more powerful/possibly riskier) conversion is occurring here. (similarly elsewhere in this patch & otherwise)<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  B -= A; // A is the same as N/2.<br>
+<br>
+  // The C coefficient is L.<br>
+  const APInt& C = L;<br>
+<br>
   // Compute the B^2-4ac term.<br>
   APInt SqrtTerm(B);<br>
   SqrtTerm *= B;<br>
@@ -7402,9 +7405,10 @@ SolveQuadraticEquation(const SCEVAddRecE<br>
<br>
   // Compute the two solutions for the quadratic formula.<br>
   // The divisions must be performed as signed divisions.<br>
-  APInt NegB(-B);<br>
-  APInt TwoA(A << 1);<br>
-  if (TwoA.isMinValue())<br>
+  APInt NegB(-std::move(B));<br>
+  APInt TwoA(std::move(A));<br>
+  TwoA <<= 1;<br>
+  if (TwoA.isNullValue())<br>
     return None;<br>
<br>
   LLVMContext &Context = SE.getContext();<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>