aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-20 20:33:18 +0000
committerDan Gohman <gohman@apple.com>2010-05-20 20:33:18 +0000
commit402d43529c18d662d1964d70dbf55bc135a8b473 (patch)
tree3cca9d2dddda6f91c11014330095d102bad30058 /lib
parent1fe591da3e83ae95f6e97d7cd432cfbb25e680e8 (diff)
downloadexternal_llvm-402d43529c18d662d1964d70dbf55bc135a8b473.tar.gz
external_llvm-402d43529c18d662d1964d70dbf55bc135a8b473.tar.bz2
external_llvm-402d43529c18d662d1964d70dbf55bc135a8b473.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp46
1 files changed, 24 insertions, 22 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 938dd2fc36..0cf7f17228 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1029,8 +1029,9 @@ void LSRUse::RecomputeRegs(size_t LUIdx, RegUseTracker &RegUses) {
// Now that we've filtered out some formulae, recompute the Regs set.
SmallPtrSet<const SCEV *, 4> OldRegs = Regs;
Regs.clear();
- for (size_t FIdx = 0, NumForms = Formulae.size(); FIdx != NumForms; ++FIdx) {
- Formula &F = Formulae[FIdx];
+ for (SmallVectorImpl<Formula>::const_iterator I = Formulae.begin(),
+ E = Formulae.end(); I != E; ++I) {
+ const Formula &F = *I;
if (F.ScaledReg) Regs.insert(F.ScaledReg);
Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end());
}
@@ -1877,9 +1878,9 @@ LSRInstance::FindUseWithSimilarFormula(const Formula &OrigF,
LU.Kind != LSRUse::ICmpZero &&
LU.Kind == OrigLU.Kind && OrigLU.AccessTy == LU.AccessTy &&
LU.HasFormulaWithSameRegs(OrigF)) {
- for (size_t FIdx = 0, NumForms = LU.Formulae.size();
- FIdx != NumForms; ++FIdx) {
- Formula &F = LU.Formulae[FIdx];
+ for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
+ E = LU.Formulae.end(); I != E; ++I) {
+ const Formula &F = *I;
if (F.BaseRegs == OrigF.BaseRegs &&
F.ScaledReg == OrigF.ScaledReg &&
F.AM.BaseGV == OrigF.AM.BaseGV &&
@@ -2867,9 +2868,9 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) {
LSRUse &LU = Uses[LUIdx];
- for (size_t FIdx = 0, NumForms = LU.Formulae.size();
- FIdx != NumForms; ++FIdx) {
- Formula &F = LU.Formulae[FIdx];
+ for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(),
+ E = LU.Formulae.end(); I != E; ++I) {
+ const Formula &F = *I;
if (F.AM.BaseOffs != 0 && F.AM.Scale == 0) {
if (LSRUse *LUThatHas = FindUseWithSimilarFormula(F, LU)) {
if (reconcileNewOffset(*LUThatHas, F.AM.BaseOffs,
@@ -2899,15 +2900,17 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
LUThatHas->RecomputeRegs(LUThatHas - &Uses.front(), RegUses);
// Update the relocs to reference the new use.
- for (size_t i = 0, e = Fixups.size(); i != e; ++i) {
- if (Fixups[i].LUIdx == LUIdx) {
- Fixups[i].LUIdx = LUThatHas - &Uses.front();
- Fixups[i].Offset += F.AM.BaseOffs;
+ for (SmallVectorImpl<LSRFixup>::iterator I = Fixups.begin(),
+ E = Fixups.end(); I != E; ++I) {
+ LSRFixup &Fixup = *I;
+ if (Fixup.LUIdx == LUIdx) {
+ Fixup.LUIdx = LUThatHas - &Uses.front();
+ Fixup.Offset += F.AM.BaseOffs;
DEBUG(errs() << "New fixup has offset "
- << Fixups[i].Offset << '\n');
+ << Fixup.Offset << '\n');
}
- if (Fixups[i].LUIdx == NumUses-1)
- Fixups[i].LUIdx = LUIdx;
+ if (Fixup.LUIdx == NumUses-1)
+ Fixup.LUIdx = LUIdx;
}
// Delete the old use.
@@ -3470,10 +3473,11 @@ LSRInstance::ImplementSolution(const SmallVectorImpl<const Formula *> &Solution,
Rewriter.setIVIncInsertPos(L, IVIncInsertPos);
// Expand the new value definitions and update the users.
- for (size_t i = 0, e = Fixups.size(); i != e; ++i) {
- size_t LUIdx = Fixups[i].LUIdx;
+ for (SmallVectorImpl<LSRFixup>::const_iterator I = Fixups.begin(),
+ 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;
}
@@ -3502,13 +3506,11 @@ LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P)
WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
dbgs() << ":\n");
- /// OptimizeShadowIV - If IV is used in a int-to-float cast
- /// inside the loop then try to eliminate the cast operation.
+ // First, perform some low-level loop optimizations.
OptimizeShadowIV();
-
- // Change loop terminating condition to use the postinc iv when possible.
OptimizeLoopTermCond();
+ // Start collecting data and preparing for the solver.
CollectInterestingTypesAndFactors();
CollectFixupsAndInitialFormulae();
CollectLoopInvariantFixupsAndFormulae();