summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-11 06:48:54 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-11 06:48:54 +0000
commite3e1a35f68f0053e24725e30f4f6a4496efab324 (patch)
tree2773e63828844f81441df90e2888665b26bb41ce /llvm
parent6694a4e6d696b7620cd2d91b44981c9bf704156a (diff)
downloadbcm5719-llvm-e3e1a35f68f0053e24725e30f4f6a4496efab324.tar.gz
bcm5719-llvm-e3e1a35f68f0053e24725e30f4f6a4496efab324.zip
[SCEV] Reduce possible APInt allocations a bit.
llvm-svn: 302769
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 76da5bd057f..17fb979f50f 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7377,15 +7377,18 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
const APInt &N = NC->getAPInt();
APInt Two(BitWidth, 2);
- const APInt& C = L;
// Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
- // The B coefficient is M-N/2
- APInt B(M);
- B -= N.sdiv(Two);
// The A coefficient is N/2
APInt A(N.sdiv(Two));
+ // The B coefficient is M-N/2
+ APInt B(M);
+ B -= A; // A is the same as N/2.
+
+ // The C coefficient is L.
+ const APInt& C = L;
+
// Compute the B^2-4ac term.
APInt SqrtTerm(B);
SqrtTerm *= B;
@@ -7402,9 +7405,10 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
// Compute the two solutions for the quadratic formula.
// The divisions must be performed as signed divisions.
- APInt NegB(-B);
- APInt TwoA(A << 1);
- if (TwoA.isMinValue())
+ APInt NegB(-std::move(B));
+ APInt TwoA(std::move(A));
+ TwoA <<= 1;
+ if (TwoA.isNullValue())
return None;
LLVMContext &Context = SE.getContext();
OpenPOWER on IntegriCloud