mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Eliminate unnecessary APInt construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6db928a62e
commit
414de4df41
@ -500,7 +500,7 @@ static SCEVHandle PartialFact(SCEVHandle V, unsigned NumSteps) {
|
|||||||
// Handle this case efficiently, it is common to have constant iteration
|
// Handle this case efficiently, it is common to have constant iteration
|
||||||
// counts while computing loop exit values.
|
// counts while computing loop exit values.
|
||||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
|
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
|
||||||
APInt Val = SC->getValue()->getValue();
|
const APInt& Val = SC->getValue()->getValue();
|
||||||
APInt Result(Val.getBitWidth(), 1);
|
APInt Result(Val.getBitWidth(), 1);
|
||||||
for (; NumSteps; --NumSteps)
|
for (; NumSteps; --NumSteps)
|
||||||
Result *= Val-(NumSteps-1);
|
Result *= Val-(NumSteps-1);
|
||||||
@ -1336,7 +1336,7 @@ SCEVHandle ScalarEvolutionsImpl::createNodeForPHI(PHINode *PN) {
|
|||||||
/// example, turn {4,+,8} -> 4. (S umod result) should always equal zero.
|
/// example, turn {4,+,8} -> 4. (S umod result) should always equal zero.
|
||||||
static APInt GetConstantFactor(SCEVHandle S) {
|
static APInt GetConstantFactor(SCEVHandle S) {
|
||||||
if (SCEVConstant *C = dyn_cast<SCEVConstant>(S)) {
|
if (SCEVConstant *C = dyn_cast<SCEVConstant>(S)) {
|
||||||
APInt V = C->getValue()->getValue();
|
const APInt& V = C->getValue()->getValue();
|
||||||
if (!V.isMinValue())
|
if (!V.isMinValue())
|
||||||
return V;
|
return V;
|
||||||
else // Zero is a multiple of everything.
|
else // Zero is a multiple of everything.
|
||||||
@ -2096,23 +2096,22 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BitWidth = LC->getValue()->getValue().getBitWidth();
|
uint32_t BitWidth = LC->getValue()->getValue().getBitWidth();
|
||||||
APInt L(LC->getValue()->getValue());
|
const APInt& L = LC->getValue()->getValue();
|
||||||
APInt M(MC->getValue()->getValue());
|
const APInt& M = MC->getValue()->getValue();
|
||||||
APInt N(MC->getValue()->getValue());
|
const APInt& N = MC->getValue()->getValue();
|
||||||
APInt Two(BitWidth, 2);
|
APInt Two(BitWidth, 2);
|
||||||
APInt Four(BitWidth, 4);
|
APInt Four(BitWidth, 4);
|
||||||
|
|
||||||
{
|
{
|
||||||
using namespace APIntOps;
|
using namespace APIntOps;
|
||||||
APInt C(L);
|
const APInt& C = L;
|
||||||
// Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
|
// Convert from chrec coefficients to polynomial coefficients AX^2+BX+C
|
||||||
// The B coefficient is M-N/2
|
// The B coefficient is M-N/2
|
||||||
APInt B(M);
|
APInt B(M);
|
||||||
B -= sdiv(N,Two);
|
B -= sdiv(N,Two);
|
||||||
|
|
||||||
// The A coefficient is N/2
|
// The A coefficient is N/2
|
||||||
APInt A(N);
|
APInt A(N.sdiv(Two));
|
||||||
A = A.sdiv(Two);
|
|
||||||
|
|
||||||
// Compute the B^2-4ac term.
|
// Compute the B^2-4ac term.
|
||||||
APInt SqrtTerm(B);
|
APInt SqrtTerm(B);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user