mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Allow indvar simplify to canonicalize ANY affine IV, not just affine IVs with
constant stride. This implements Transforms/IndVarsSimplify/variable-stride-ivs.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a12489e34f
commit
cda9ca5a4f
@ -130,7 +130,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
|
|||||||
if (GetElementPtrInst *GEPI =
|
if (GetElementPtrInst *GEPI =
|
||||||
dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx)))
|
dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx)))
|
||||||
if (GEPI->getOperand(0) == PN) {
|
if (GEPI->getOperand(0) == PN) {
|
||||||
assert(GEPI->getNumOperands() == 2 && "GEP types must mismatch!");
|
assert(GEPI->getNumOperands() == 2 && "GEP types must match!");
|
||||||
|
|
||||||
// Okay, we found a pointer recurrence. Transform this pointer
|
// Okay, we found a pointer recurrence. Transform this pointer
|
||||||
// recurrence into an integer recurrence. Compute the value that gets
|
// recurrence into an integer recurrence. Compute the value that gets
|
||||||
@ -407,13 +407,13 @@ void IndVarSimplify::runOnLoop(Loop *L) {
|
|||||||
if (PN->getType()->isInteger()) { // FIXME: when we have fast-math, enable!
|
if (PN->getType()->isInteger()) { // FIXME: when we have fast-math, enable!
|
||||||
SCEVHandle SCEV = SE->getSCEV(PN);
|
SCEVHandle SCEV = SE->getSCEV(PN);
|
||||||
if (SCEV->hasComputableLoopEvolution(L))
|
if (SCEV->hasComputableLoopEvolution(L))
|
||||||
// FIXME: Without a strength reduction pass, it is an extremely bad idea
|
// FIXME: It is an extremely bad idea to indvar substitute anything more
|
||||||
// to indvar substitute anything more complex than a linear induction
|
// complex than affine induction variables. Doing so will put expensive
|
||||||
// variable. Doing so will put expensive multiply instructions inside
|
// polynomial evaluations inside of the loop, and the str reduction pass
|
||||||
// of the loop. For now just disable indvar subst on anything more
|
// currently can only reduce affine polynomials. For now just disable
|
||||||
// complex than a linear addrec.
|
// indvar subst on anything more complex than an affine addrec.
|
||||||
if (SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
|
if (SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
|
||||||
if (AR->getNumOperands() == 2 && isa<SCEVConstant>(AR->getOperand(1)))
|
if (AR->isAffine())
|
||||||
IndVars.push_back(std::make_pair(PN, SCEV));
|
IndVars.push_back(std::make_pair(PN, SCEV));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user