@@ -14593,13 +14593,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
1459314593 };
1459414594 if (!ValueToExtUses) {
1459514595 ValueToExtUses.emplace();
14596- for_each(enumerate(ExternalUses), [&] (const auto &P) {
14596+ for (const auto &P : enumerate(ExternalUses) ) {
1459714597 // Ignore phis in loops.
1459814598 if (IsPhiInLoop(P.value()))
14599- return ;
14599+ continue ;
1460014600
1460114601 ValueToExtUses->try_emplace(P.value().Scalar, P.index());
14602- });
14602+ }
1460314603 }
1460414604 // Can use original instruction, if no operands vectorized or they are
1460514605 // marked as externally used already.
@@ -14677,13 +14677,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
1467714677 }
1467814678 if (KeepScalar) {
1467914679 ExternalUsesAsOriginalScalar.insert(EU.Scalar);
14680- for_each( Inst->operands(), [&](Value *V ) {
14680+ for (Value *V : Inst->operands()) {
1468114681 auto It = ValueToExtUses->find(V);
1468214682 if (It != ValueToExtUses->end()) {
1468314683 // Replace all uses to avoid compiler crash.
1468414684 ExternalUses[It->second].User = nullptr;
1468514685 }
14686- });
14686+ }
1468714687 ExtraCost = ScalarCost;
1468814688 if (!IsPhiInLoop(EU))
1468914689 ExtractsCount[Entry].insert(Inst);
@@ -14692,13 +14692,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
1469214692 // Update the users of the operands of the cast operand to avoid
1469314693 // compiler crash.
1469414694 if (auto *IOp = dyn_cast<Instruction>(Inst->getOperand(0))) {
14695- for_each( IOp->operands(), [&](Value *V ) {
14695+ for (Value *V : IOp->operands()) {
1469614696 auto It = ValueToExtUses->find(V);
1469714697 if (It != ValueToExtUses->end()) {
1469814698 // Replace all uses to avoid compiler crash.
1469914699 ExternalUses[It->second].User = nullptr;
1470014700 }
14701- });
14701+ }
1470214702 }
1470314703 }
1470414704 }
@@ -15334,7 +15334,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1533415334 // tree.
1533515335 Entries.push_back(FirstEntries.front());
1533615336 // Update mapping between values and corresponding tree entries.
15337- for_each(UsedValuesEntry, [&](auto &P) { P.second = 0; });
15337+ for (auto &P : UsedValuesEntry)
15338+ P.second = 0;
1533815339 VF = FirstEntries.front()->getVectorFactor();
1533915340 } else {
1534015341 // Try to find nodes with the same vector factor.
@@ -15384,13 +15385,13 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1538415385 ValuesToEntries.emplace_back().insert(E->Scalars.begin(),
1538515386 E->Scalars.end());
1538615387 // Update mapping between values and corresponding tree entries.
15387- for_each(UsedValuesEntry, [&] (auto &P) {
15388+ for (auto &P : UsedValuesEntry ) {
1538815389 for (unsigned Idx : seq<unsigned>(ValuesToEntries.size()))
1538915390 if (ValuesToEntries[Idx].contains(P.first)) {
1539015391 P.second = Idx;
1539115392 break;
1539215393 }
15393- });
15394+ }
1539415395 }
1539515396
1539615397 bool IsSplatOrUndefs = isSplat(VL) || all_of(VL, IsaPred<UndefValue>);
@@ -15536,12 +15537,12 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1553615537 (MaxElement % VF) -
1553715538 (MinElement % VF) + 1));
1553815539 if (NewVF < VF) {
15539- for_each(SubMask, [&] (int &Idx) {
15540+ for (int &Idx : SubMask ) {
1554015541 if (Idx == PoisonMaskElem)
15541- return ;
15542+ continue ;
1554215543 Idx = ((Idx % VF) - (((MinElement % VF) / NewVF) * NewVF)) % NewVF +
1554315544 (Idx >= static_cast<int>(VF) ? NewVF : 0);
15544- });
15545+ }
1554515546 } else {
1554615547 NewVF = VF;
1554715548 }
@@ -19306,8 +19307,10 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
1930619307 // whole bundle might not be ready.
1930719308 ReadyInsts.remove(BundleMember);
1930819309 if (ArrayRef<ScheduleBundle *> Bundles = getScheduleBundles(V);
19309- !Bundles.empty())
19310- for_each(Bundles, [&](ScheduleBundle *B) { ReadyInsts.remove(B); });
19310+ !Bundles.empty()) {
19311+ for (ScheduleBundle *B : Bundles)
19312+ ReadyInsts.remove(B);
19313+ }
1931119314
1931219315 if (!BundleMember->isScheduled())
1931319316 continue;
@@ -19632,23 +19635,23 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
1963219635 }
1963319636 continue;
1963419637 }
19635- for_each(Bundles, [&] (ScheduleBundle *Bundle) {
19638+ for (ScheduleBundle *Bundle : Bundles ) {
1963619639 if (!Visited.insert(Bundle).second || Bundle->hasValidDependencies())
19637- return ;
19640+ continue ;
1963819641 assert(isInSchedulingRegion(*Bundle) &&
1963919642 "ScheduleData not in scheduling region");
1964019643 for_each(Bundle->getBundle(), ProcessNode);
19641- });
19644+ }
1964219645 if (InsertInReadyList && SD->isReady()) {
19643- for_each(Bundles, [&] (ScheduleBundle *Bundle) {
19646+ for (ScheduleBundle *Bundle : Bundles ) {
1964419647 assert(isInSchedulingRegion(*Bundle) &&
1964519648 "ScheduleData not in scheduling region");
1964619649 if (!Bundle->isReady())
19647- return ;
19650+ continue ;
1964819651 ReadyInsts.insert(Bundle);
1964919652 LLVM_DEBUG(dbgs() << "SLP: gets ready on update: " << *Bundle
1965019653 << "\n");
19651- });
19654+ }
1965219655 }
1965319656 }
1965419657}
@@ -20032,8 +20035,8 @@ bool BoUpSLP::collectValuesToDemote(
2003220035 if (Operands.empty()) {
2003320036 if (!IsTruncRoot)
2003420037 MaxDepthLevel = 1;
20035- (void)for_each(E.Scalars, std::bind(IsPotentiallyTruncated, _1,
20036- std::ref(BitWidth)) );
20038+ for (Value *V : E.Scalars)
20039+ (void)IsPotentiallyTruncated(V, BitWidth );
2003720040 } else {
2003820041 // Several vectorized uses? Check if we can truncate it, otherwise -
2003920042 // exit.
@@ -21034,17 +21037,16 @@ bool SLPVectorizerPass::vectorizeStores(
2103421037 unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
2103521038 SmallVector<unsigned> CandidateVFs(Sz + (NonPowerOf2VF > 0 ? 1 : 0));
2103621039 unsigned Size = MinVF;
21037- for_each(reverse(CandidateVFs), [&] (unsigned &VF) {
21040+ for (unsigned &VF : reverse(CandidateVFs) ) {
2103821041 VF = Size > MaxVF ? NonPowerOf2VF : Size;
2103921042 Size *= 2;
21040- });
21043+ }
2104121044 unsigned End = Operands.size();
2104221045 unsigned Repeat = 0;
2104321046 constexpr unsigned MaxAttempts = 4;
2104421047 OwningArrayRef<std::pair<unsigned, unsigned>> RangeSizes(Operands.size());
21045- for_each(RangeSizes, [] (std::pair<unsigned, unsigned> &P) {
21048+ for (std::pair<unsigned, unsigned> &P : RangeSizes)
2104621049 P.first = P.second = 1;
21047- });
2104821050 DenseMap<Value *, std::pair<unsigned, unsigned>> NonSchedulable;
2104921051 auto IsNotVectorized = [](bool First,
2105021052 const std::pair<unsigned, unsigned> &P) {
@@ -21120,22 +21122,19 @@ bool SLPVectorizerPass::vectorizeStores(
2112021122 AnyProfitableGraph = RepeatChanged = Changed = true;
2112121123 // If we vectorized initial block, no need to try to vectorize
2112221124 // it again.
21123- for_each(RangeSizes.slice(Cnt, Size),
21124- [](std::pair<unsigned, unsigned> &P) {
21125- P.first = P.second = 0;
21126- });
21125+ for (std::pair<unsigned, unsigned> &P :
21126+ RangeSizes.slice(Cnt, Size))
21127+ P.first = P.second = 0;
2112721128 if (Cnt < StartIdx + MinVF) {
21128- for_each(RangeSizes.slice(StartIdx, Cnt - StartIdx),
21129- [](std::pair<unsigned, unsigned> &P) {
21130- P.first = P.second = 0;
21131- });
21129+ for (std::pair<unsigned, unsigned> &P :
21130+ RangeSizes.slice(StartIdx, Cnt - StartIdx))
21131+ P.first = P.second = 0;
2113221132 StartIdx = Cnt + Size;
2113321133 }
2113421134 if (Cnt > Sz - Size - MinVF) {
21135- for_each(RangeSizes.slice(Cnt + Size, Sz - (Cnt + Size)),
21136- [](std::pair<unsigned, unsigned> &P) {
21137- P.first = P.second = 0;
21138- });
21135+ for (std::pair<unsigned, unsigned> &P :
21136+ RangeSizes.slice(Cnt + Size, Sz - (Cnt + Size)))
21137+ P.first = P.second = 0;
2113921138 if (Sz == End)
2114021139 End = Cnt;
2114121140 Sz = Cnt;
@@ -21161,13 +21160,13 @@ bool SLPVectorizerPass::vectorizeStores(
2116121160 continue;
2116221161 }
2116321162 if (TreeSize > 1)
21164- for_each(RangeSizes.slice(Cnt, Size),
21165- [&](std::pair<unsigned, unsigned> &P ) {
21166- if (Size >= MaxRegVF)
21167- P.second = std::max(P.second, TreeSize);
21168- else
21169- P.first = std::max(P.first, TreeSize);
21170- });
21163+ for (std::pair<unsigned, unsigned> &P :
21164+ RangeSizes.slice(Cnt, Size) ) {
21165+ if (Size >= MaxRegVF)
21166+ P.second = std::max(P.second, TreeSize);
21167+ else
21168+ P.first = std::max(P.first, TreeSize);
21169+ }
2117121170 ++Cnt;
2117221171 AnyProfitableGraph = true;
2117321172 }
@@ -21209,10 +21208,10 @@ bool SLPVectorizerPass::vectorizeStores(
2120921208 CandidateVFs.push_back(Limit);
2121021209 if (VF > MaxTotalNum || VF >= StoresLimit)
2121121210 break;
21212- for_each(RangeSizes, [&] (std::pair<unsigned, unsigned> &P) {
21211+ for (std::pair<unsigned, unsigned> &P : RangeSizes ) {
2121321212 if (P.first != 0)
2121421213 P.first = std::max(P.second, P.first);
21215- });
21214+ }
2121621215 // Last attempt to vectorize max number of elements, if all previous
2121721216 // attempts were unsuccessful because of the cost issues.
2121821217 CandidateVFs.push_back(VF);
0 commit comments