mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
More code cleanups. Use iterators instead of indices when indices
aren't needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1029,8 +1029,9 @@ void LSRUse::RecomputeRegs(size_t LUIdx, RegUseTracker &RegUses) {
|
|||||||
// Now that we've filtered out some formulae, recompute the Regs set.
|
// Now that we've filtered out some formulae, recompute the Regs set.
|
||||||
SmallPtrSet<const SCEV *, 4> OldRegs = Regs;
|
SmallPtrSet<const SCEV *, 4> OldRegs = Regs;
|
||||||
Regs.clear();
|
Regs.clear();
|
||||||
for (size_t FIdx = 0, NumForms = Formulae.size(); FIdx != NumForms; ++FIdx) {
|
for (SmallVectorImpl<Formula>::const_iterator I = Formulae.begin(),
|
||||||
Formula &F = Formulae[FIdx];
|
E = Formulae.end(); I != E; ++I) {
|
||||||
|
const Formula &F = *I;
|
||||||
if (F.ScaledReg) Regs.insert(F.ScaledReg);
|
if (F.ScaledReg) Regs.insert(F.ScaledReg);
|
||||||
Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end());
|
Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end());
|
||||||
}
|
}
|
||||||
@@ -1877,9 +1878,9 @@ LSRInstance::FindUseWithSimilarFormula(const Formula &OrigF,
|
|||||||
LU.Kind != LSRUse::ICmpZero &&
|
LU.Kind != LSRUse::ICmpZero &&
|
||||||
LU.Kind == OrigLU.Kind && OrigLU.AccessTy == LU.AccessTy &&
|
LU.Kind == OrigLU.Kind && OrigLU.AccessTy == LU.AccessTy &&
|
||||||
LU.HasFormulaWithSameRegs(OrigF)) {
|
LU.HasFormulaWithSameRegs(OrigF)) {
|
||||||
for (size_t FIdx = 0, NumForms = LU.Formulae.size();
|
for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
|
||||||
FIdx != NumForms; ++FIdx) {
|
E = LU.Formulae.end(); I != E; ++I) {
|
||||||
Formula &F = LU.Formulae[FIdx];
|
const Formula &F = *I;
|
||||||
if (F.BaseRegs == OrigF.BaseRegs &&
|
if (F.BaseRegs == OrigF.BaseRegs &&
|
||||||
F.ScaledReg == OrigF.ScaledReg &&
|
F.ScaledReg == OrigF.ScaledReg &&
|
||||||
F.AM.BaseGV == OrigF.AM.BaseGV &&
|
F.AM.BaseGV == OrigF.AM.BaseGV &&
|
||||||
@@ -2867,9 +2868,9 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
|
|||||||
|
|
||||||
for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) {
|
for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) {
|
||||||
LSRUse &LU = Uses[LUIdx];
|
LSRUse &LU = Uses[LUIdx];
|
||||||
for (size_t FIdx = 0, NumForms = LU.Formulae.size();
|
for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
|
||||||
FIdx != NumForms; ++FIdx) {
|
E = LU.Formulae.end(); I != E; ++I) {
|
||||||
Formula &F = LU.Formulae[FIdx];
|
const Formula &F = *I;
|
||||||
if (F.AM.BaseOffs != 0 && F.AM.Scale == 0) {
|
if (F.AM.BaseOffs != 0 && F.AM.Scale == 0) {
|
||||||
if (LSRUse *LUThatHas = FindUseWithSimilarFormula(F, LU)) {
|
if (LSRUse *LUThatHas = FindUseWithSimilarFormula(F, LU)) {
|
||||||
if (reconcileNewOffset(*LUThatHas, F.AM.BaseOffs,
|
if (reconcileNewOffset(*LUThatHas, F.AM.BaseOffs,
|
||||||
@@ -2899,15 +2900,17 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
|
|||||||
LUThatHas->RecomputeRegs(LUThatHas - &Uses.front(), RegUses);
|
LUThatHas->RecomputeRegs(LUThatHas - &Uses.front(), RegUses);
|
||||||
|
|
||||||
// Update the relocs to reference the new use.
|
// Update the relocs to reference the new use.
|
||||||
for (size_t i = 0, e = Fixups.size(); i != e; ++i) {
|
for (SmallVectorImpl<LSRFixup>::iterator I = Fixups.begin(),
|
||||||
if (Fixups[i].LUIdx == LUIdx) {
|
E = Fixups.end(); I != E; ++I) {
|
||||||
Fixups[i].LUIdx = LUThatHas - &Uses.front();
|
LSRFixup &Fixup = *I;
|
||||||
Fixups[i].Offset += F.AM.BaseOffs;
|
if (Fixup.LUIdx == LUIdx) {
|
||||||
|
Fixup.LUIdx = LUThatHas - &Uses.front();
|
||||||
|
Fixup.Offset += F.AM.BaseOffs;
|
||||||
DEBUG(errs() << "New fixup has offset "
|
DEBUG(errs() << "New fixup has offset "
|
||||||
<< Fixups[i].Offset << '\n');
|
<< Fixup.Offset << '\n');
|
||||||
}
|
}
|
||||||
if (Fixups[i].LUIdx == NumUses-1)
|
if (Fixup.LUIdx == NumUses-1)
|
||||||
Fixups[i].LUIdx = LUIdx;
|
Fixup.LUIdx = LUIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the old use.
|
// Delete the old use.
|
||||||
@@ -3470,10 +3473,11 @@ LSRInstance::ImplementSolution(const SmallVectorImpl<const Formula *> &Solution,
|
|||||||
Rewriter.setIVIncInsertPos(L, IVIncInsertPos);
|
Rewriter.setIVIncInsertPos(L, IVIncInsertPos);
|
||||||
|
|
||||||
// Expand the new value definitions and update the users.
|
// Expand the new value definitions and update the users.
|
||||||
for (size_t i = 0, e = Fixups.size(); i != e; ++i) {
|
for (SmallVectorImpl<LSRFixup>::const_iterator I = Fixups.begin(),
|
||||||
size_t LUIdx = Fixups[i].LUIdx;
|
E = Fixups.end(); I != E; ++I) {
|
||||||
|
const LSRFixup &Fixup = *I;
|
||||||
|
|
||||||
Rewrite(Fixups[i], *Solution[LUIdx], Rewriter, DeadInsts, P);
|
Rewrite(Fixup, *Solution[Fixup.LUIdx], Rewriter, DeadInsts, P);
|
||||||
|
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
@@ -3502,13 +3506,11 @@ LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P)
|
|||||||
WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
|
WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
|
||||||
dbgs() << ":\n");
|
dbgs() << ":\n");
|
||||||
|
|
||||||
/// OptimizeShadowIV - If IV is used in a int-to-float cast
|
// First, perform some low-level loop optimizations.
|
||||||
/// inside the loop then try to eliminate the cast operation.
|
|
||||||
OptimizeShadowIV();
|
OptimizeShadowIV();
|
||||||
|
|
||||||
// Change loop terminating condition to use the postinc iv when possible.
|
|
||||||
OptimizeLoopTermCond();
|
OptimizeLoopTermCond();
|
||||||
|
|
||||||
|
// Start collecting data and preparing for the solver.
|
||||||
CollectInterestingTypesAndFactors();
|
CollectInterestingTypesAndFactors();
|
||||||
CollectFixupsAndInitialFormulae();
|
CollectFixupsAndInitialFormulae();
|
||||||
CollectLoopInvariantFixupsAndFormulae();
|
CollectLoopInvariantFixupsAndFormulae();
|
||||||
|
Reference in New Issue
Block a user