Skip to content

Commit e749757

Browse files
[Vectorize] Use range-based for loops (NFC)
1 parent aaa79a5 commit e749757

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,9 +4677,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
46774677
// Currently the are vectorized loads,extracts without alternate operands +
46784678
// some gathering of extracts.
46794679
SmallVector<TreeEntry *> NonVectorized;
4680-
for_each(VectorizableTree, [this, &OrderedEntries, &GathersToOrders,
4681-
&NonVectorized](
4682-
const std::unique_ptr<TreeEntry> &TE) {
4680+
for (const std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
46834681
if (TE->State != TreeEntry::Vectorize &&
46844682
TE->State != TreeEntry::PossibleStridedVectorize)
46854683
NonVectorized.push_back(TE.get());
@@ -4691,7 +4689,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
46914689
!TE->ReuseShuffleIndices.empty())
46924690
GathersToOrders.try_emplace(TE.get(), *CurrentOrder);
46934691
}
4694-
});
4692+
}
46954693

46964694
// 1. Propagate order to the graph nodes, which use only reordered nodes.
46974695
// I.e., if the node has operands, that are reordered, try to make at least
@@ -4728,8 +4726,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
47284726
}
47294727
}
47304728
// Erase filtered entries.
4731-
for_each(Filtered,
4732-
[&OrderedEntries](TreeEntry *TE) { OrderedEntries.remove(TE); });
4729+
for (TreeEntry *TE : Filtered)
4730+
OrderedEntries.remove(TE);
47334731
SmallVector<
47344732
std::pair<TreeEntry *, SmallVector<std::pair<unsigned, TreeEntry *>>>>
47354733
UsersVec(Users.begin(), Users.end());
@@ -4741,10 +4739,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
47414739
SmallVector<TreeEntry *> GatherOps;
47424740
if (!canReorderOperands(Data.first, Data.second, NonVectorized,
47434741
GatherOps)) {
4744-
for_each(Data.second,
4745-
[&OrderedEntries](const std::pair<unsigned, TreeEntry *> &Op) {
4746-
OrderedEntries.remove(Op.second);
4747-
});
4742+
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
4743+
OrderedEntries.remove(Op.second);
47484744
continue;
47494745
}
47504746
// All operands are reordered and used only in this node - propagate the
@@ -4846,11 +4842,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
48464842
Data.first->ReuseShuffleIndices.empty() &&
48474843
!(IgnoreReorder &&
48484844
Data.first == VectorizableTree.front().get()))) {
4849-
for_each(
4850-
Data.second,
4851-
[&OrderedEntries](const std::pair<unsigned, TreeEntry *> &Op) {
4852-
OrderedEntries.remove(Op.second);
4853-
});
4845+
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
4846+
OrderedEntries.remove(Op.second);
48544847
continue;
48554848
}
48564849
// Add (potentially!) strided vectorize orders.
@@ -4877,10 +4870,8 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
48774870
}
48784871
// Set order of the user node (reordering of operands and user nodes).
48794872
if (BestOrder.empty()) {
4880-
for_each(Data.second,
4881-
[&OrderedEntries](const std::pair<unsigned, TreeEntry *> &Op) {
4882-
OrderedEntries.remove(Op.second);
4883-
});
4873+
for (const std::pair<unsigned, TreeEntry *> &Op : Data.second)
4874+
OrderedEntries.remove(Op.second);
48844875
continue;
48854876
}
48864877
// Erase operands from OrderedEntries list and adjust their orders.
@@ -13904,11 +13895,9 @@ class HorizontalReduction {
1390413895
for (unsigned Cnt = 0, Sz = ReducedVals.size(); Cnt < Sz; ++Cnt) {
1390513896
if (Cnt == I || (ShuffledExtracts && Cnt == I - 1))
1390613897
continue;
13907-
for_each(ReducedVals[Cnt],
13908-
[&LocalExternallyUsedValues, &TrackedVals](Value *V) {
13909-
if (isa<Instruction>(V))
13910-
LocalExternallyUsedValues[TrackedVals[V]];
13911-
});
13898+
for (Value *V : ReducedVals[Cnt])
13899+
if (isa<Instruction>(V))
13900+
LocalExternallyUsedValues[TrackedVals[V]];
1391213901
}
1391313902
if (!IsSupportedHorRdxIdentityOp) {
1391413903
// Number of uses of the candidates in the vector of values.

0 commit comments

Comments
 (0)