@@ -14593,13 +14593,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
14593
14593
};
14594
14594
if (!ValueToExtUses) {
14595
14595
ValueToExtUses.emplace();
14596
- for_each(enumerate(ExternalUses), [&] (const auto &P) {
14596
+ for (const auto &P : enumerate(ExternalUses) ) {
14597
14597
// Ignore phis in loops.
14598
14598
if (IsPhiInLoop(P.value()))
14599
- return ;
14599
+ continue ;
14600
14600
14601
14601
ValueToExtUses->try_emplace(P.value().Scalar, P.index());
14602
- });
14602
+ }
14603
14603
}
14604
14604
// Can use original instruction, if no operands vectorized or they are
14605
14605
// marked as externally used already.
@@ -14677,13 +14677,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
14677
14677
}
14678
14678
if (KeepScalar) {
14679
14679
ExternalUsesAsOriginalScalar.insert(EU.Scalar);
14680
- for_each( Inst->operands(), [&](Value *V ) {
14680
+ for (Value *V : Inst->operands()) {
14681
14681
auto It = ValueToExtUses->find(V);
14682
14682
if (It != ValueToExtUses->end()) {
14683
14683
// Replace all uses to avoid compiler crash.
14684
14684
ExternalUses[It->second].User = nullptr;
14685
14685
}
14686
- });
14686
+ }
14687
14687
ExtraCost = ScalarCost;
14688
14688
if (!IsPhiInLoop(EU))
14689
14689
ExtractsCount[Entry].insert(Inst);
@@ -14692,13 +14692,13 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
14692
14692
// Update the users of the operands of the cast operand to avoid
14693
14693
// compiler crash.
14694
14694
if (auto *IOp = dyn_cast<Instruction>(Inst->getOperand(0))) {
14695
- for_each( IOp->operands(), [&](Value *V ) {
14695
+ for (Value *V : IOp->operands()) {
14696
14696
auto It = ValueToExtUses->find(V);
14697
14697
if (It != ValueToExtUses->end()) {
14698
14698
// Replace all uses to avoid compiler crash.
14699
14699
ExternalUses[It->second].User = nullptr;
14700
14700
}
14701
- });
14701
+ }
14702
14702
}
14703
14703
}
14704
14704
}
@@ -15334,7 +15334,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
15334
15334
// tree.
15335
15335
Entries.push_back(FirstEntries.front());
15336
15336
// 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;
15338
15339
VF = FirstEntries.front()->getVectorFactor();
15339
15340
} else {
15340
15341
// Try to find nodes with the same vector factor.
@@ -15384,13 +15385,13 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
15384
15385
ValuesToEntries.emplace_back().insert(E->Scalars.begin(),
15385
15386
E->Scalars.end());
15386
15387
// Update mapping between values and corresponding tree entries.
15387
- for_each(UsedValuesEntry, [&] (auto &P) {
15388
+ for (auto &P : UsedValuesEntry ) {
15388
15389
for (unsigned Idx : seq<unsigned>(ValuesToEntries.size()))
15389
15390
if (ValuesToEntries[Idx].contains(P.first)) {
15390
15391
P.second = Idx;
15391
15392
break;
15392
15393
}
15393
- });
15394
+ }
15394
15395
}
15395
15396
15396
15397
bool IsSplatOrUndefs = isSplat(VL) || all_of(VL, IsaPred<UndefValue>);
@@ -15536,12 +15537,12 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
15536
15537
(MaxElement % VF) -
15537
15538
(MinElement % VF) + 1));
15538
15539
if (NewVF < VF) {
15539
- for_each(SubMask, [&] (int &Idx) {
15540
+ for (int &Idx : SubMask ) {
15540
15541
if (Idx == PoisonMaskElem)
15541
- return ;
15542
+ continue ;
15542
15543
Idx = ((Idx % VF) - (((MinElement % VF) / NewVF) * NewVF)) % NewVF +
15543
15544
(Idx >= static_cast<int>(VF) ? NewVF : 0);
15544
- });
15545
+ }
15545
15546
} else {
15546
15547
NewVF = VF;
15547
15548
}
@@ -19306,8 +19307,10 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef<Value *> VL, BoUpSLP *SLP,
19306
19307
// whole bundle might not be ready.
19307
19308
ReadyInsts.remove(BundleMember);
19308
19309
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
+ }
19311
19314
19312
19315
if (!BundleMember->isScheduled())
19313
19316
continue;
@@ -19632,23 +19635,23 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleBundle &Bundle,
19632
19635
}
19633
19636
continue;
19634
19637
}
19635
- for_each(Bundles, [&] (ScheduleBundle *Bundle) {
19638
+ for (ScheduleBundle *Bundle : Bundles ) {
19636
19639
if (!Visited.insert(Bundle).second || Bundle->hasValidDependencies())
19637
- return ;
19640
+ continue ;
19638
19641
assert(isInSchedulingRegion(*Bundle) &&
19639
19642
"ScheduleData not in scheduling region");
19640
19643
for_each(Bundle->getBundle(), ProcessNode);
19641
- });
19644
+ }
19642
19645
if (InsertInReadyList && SD->isReady()) {
19643
- for_each(Bundles, [&] (ScheduleBundle *Bundle) {
19646
+ for (ScheduleBundle *Bundle : Bundles ) {
19644
19647
assert(isInSchedulingRegion(*Bundle) &&
19645
19648
"ScheduleData not in scheduling region");
19646
19649
if (!Bundle->isReady())
19647
- return ;
19650
+ continue ;
19648
19651
ReadyInsts.insert(Bundle);
19649
19652
LLVM_DEBUG(dbgs() << "SLP: gets ready on update: " << *Bundle
19650
19653
<< "\n");
19651
- });
19654
+ }
19652
19655
}
19653
19656
}
19654
19657
}
@@ -20032,8 +20035,8 @@ bool BoUpSLP::collectValuesToDemote(
20032
20035
if (Operands.empty()) {
20033
20036
if (!IsTruncRoot)
20034
20037
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 );
20037
20040
} else {
20038
20041
// Several vectorized uses? Check if we can truncate it, otherwise -
20039
20042
// exit.
@@ -21034,17 +21037,16 @@ bool SLPVectorizerPass::vectorizeStores(
21034
21037
unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
21035
21038
SmallVector<unsigned> CandidateVFs(Sz + (NonPowerOf2VF > 0 ? 1 : 0));
21036
21039
unsigned Size = MinVF;
21037
- for_each(reverse(CandidateVFs), [&] (unsigned &VF) {
21040
+ for (unsigned &VF : reverse(CandidateVFs) ) {
21038
21041
VF = Size > MaxVF ? NonPowerOf2VF : Size;
21039
21042
Size *= 2;
21040
- });
21043
+ }
21041
21044
unsigned End = Operands.size();
21042
21045
unsigned Repeat = 0;
21043
21046
constexpr unsigned MaxAttempts = 4;
21044
21047
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)
21046
21049
P.first = P.second = 1;
21047
- });
21048
21050
DenseMap<Value *, std::pair<unsigned, unsigned>> NonSchedulable;
21049
21051
auto IsNotVectorized = [](bool First,
21050
21052
const std::pair<unsigned, unsigned> &P) {
@@ -21120,22 +21122,19 @@ bool SLPVectorizerPass::vectorizeStores(
21120
21122
AnyProfitableGraph = RepeatChanged = Changed = true;
21121
21123
// If we vectorized initial block, no need to try to vectorize
21122
21124
// 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;
21127
21128
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;
21132
21132
StartIdx = Cnt + Size;
21133
21133
}
21134
21134
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;
21139
21138
if (Sz == End)
21140
21139
End = Cnt;
21141
21140
Sz = Cnt;
@@ -21161,13 +21160,13 @@ bool SLPVectorizerPass::vectorizeStores(
21161
21160
continue;
21162
21161
}
21163
21162
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
+ }
21171
21170
++Cnt;
21172
21171
AnyProfitableGraph = true;
21173
21172
}
@@ -21209,10 +21208,10 @@ bool SLPVectorizerPass::vectorizeStores(
21209
21208
CandidateVFs.push_back(Limit);
21210
21209
if (VF > MaxTotalNum || VF >= StoresLimit)
21211
21210
break;
21212
- for_each(RangeSizes, [&] (std::pair<unsigned, unsigned> &P) {
21211
+ for (std::pair<unsigned, unsigned> &P : RangeSizes ) {
21213
21212
if (P.first != 0)
21214
21213
P.first = std::max(P.second, P.first);
21215
- });
21214
+ }
21216
21215
// Last attempt to vectorize max number of elements, if all previous
21217
21216
// attempts were unsuccessful because of the cost issues.
21218
21217
CandidateVFs.push_back(VF);
0 commit comments