llvm.org GIT mirror llvm / 4f3a92f
[SCEV] Remove unneeded 'using namespace APIntOps'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302768 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
1 changed file(s) with 39 addition(s) and 42 deletion(s). Raw diff Collapse all Expand all
73767376 const APInt &N = NC->getAPInt();
73777377 APInt Two(BitWidth, 2);
73787378
7379 {
7380 using namespace APIntOps;
7381 const APInt& C = L;
7382 // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
7383 // The B coefficient is M-N/2
7384 APInt B(M);
7385 B -= N.sdiv(Two);
7386
7387 // The A coefficient is N/2
7388 APInt A(N.sdiv(Two));
7389
7390 // Compute the B^2-4ac term.
7391 APInt SqrtTerm(B);
7392 SqrtTerm *= B;
7393 SqrtTerm -= 4 * (A * C);
7394
7395 if (SqrtTerm.isNegative()) {
7396 // The loop is provably infinite.
7397 return None;
7398 }
7399
7400 // Compute sqrt(B^2-4ac). This is guaranteed to be the nearest
7401 // integer value or else APInt::sqrt() will assert.
7402 APInt SqrtVal(SqrtTerm.sqrt());
7403
7404 // Compute the two solutions for the quadratic formula.
7405 // The divisions must be performed as signed divisions.
7406 APInt NegB(-B);
7407 APInt TwoA(A << 1);
7408 if (TwoA.isMinValue())
7409 return None;
7410
7411 LLVMContext &Context = SE.getContext();
7412
7413 ConstantInt *Solution1 =
7414 ConstantInt::get(Context, (NegB + SqrtVal).sdiv(TwoA));
7415 ConstantInt *Solution2 =
7416 ConstantInt::get(Context, (NegB - SqrtVal).sdiv(TwoA));
7417
7418 return std::make_pair(cast(SE.getConstant(Solution1)),
7419 cast(SE.getConstant(Solution2)));
7420 } // end APIntOps namespace
7379 const APInt& C = L;
7380 // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
7381 // The B coefficient is M-N/2
7382 APInt B(M);
7383 B -= N.sdiv(Two);
7384
7385 // The A coefficient is N/2
7386 APInt A(N.sdiv(Two));
7387
7388 // Compute the B^2-4ac term.
7389 APInt SqrtTerm(B);
7390 SqrtTerm *= B;
7391 SqrtTerm -= 4 * (A * C);
7392
7393 if (SqrtTerm.isNegative()) {
7394 // The loop is provably infinite.
7395 return None;
7396 }
7397
7398 // Compute sqrt(B^2-4ac). This is guaranteed to be the nearest
7399 // integer value or else APInt::sqrt() will assert.
7400 APInt SqrtVal(SqrtTerm.sqrt());
7401
7402 // Compute the two solutions for the quadratic formula.
7403 // The divisions must be performed as signed divisions.
7404 APInt NegB(-B);
7405 APInt TwoA(A << 1);
7406 if (TwoA.isMinValue())
7407 return None;
7408
7409 LLVMContext &Context = SE.getContext();
7410
7411 ConstantInt *Solution1 =
7412 ConstantInt::get(Context, (NegB + SqrtVal).sdiv(TwoA));
7413 ConstantInt *Solution2 =
7414 ConstantInt::get(Context, (NegB - SqrtVal).sdiv(TwoA));
7415
7416 return std::make_pair(cast(SE.getConstant(Solution1)),
7417 cast(SE.getConstant(Solution2)));
74217418 }
74227419
74237420 ScalarEvolution::ExitLimit