Skip to content

Commit d43697c

Browse files
committed
fixup! [SLP] More OOP to simplify vectorizeStores() (NFC)
1 parent b779e84 commit d43697c

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20544,20 +20544,15 @@ class RelatedStoreInsts {
2054420544

2054520545
/// Remove all stores that have been vectorized from this group.
2054620546
void clearVectorizedStores(const BoUpSLP::ValueSet &VectorizedStores) {
20547-
const auto Begin = Instrs.begin();
20548-
auto NonVectorizedStore = Instrs.end();
20549-
20550-
while (NonVectorizedStore != Begin) {
20551-
const auto Prev = std::prev(NonVectorizedStore);
20552-
unsigned InstrIdx = Prev->second;
20553-
if (VectorizedStores.contains(AllStores[InstrIdx])) {
20554-
// NonVectorizedStore is the last scalar instruction.
20555-
// Erase all stores before it so we don't try to vectorize them again.
20556-
Instrs.erase(Begin, NonVectorizedStore);
20557-
return;
20558-
}
20559-
NonVectorizedStore = Prev;
20560-
}
20547+
DistToInstMap::reverse_iterator LastVectorizedStore = find_if(
20548+
reverse(Instrs), [&](const std::pair<int, unsigned> &DistAndIdx) {
20549+
return VectorizedStores.contains(AllStores[DistAndIdx.second]);
20550+
});
20551+
20552+
// Get a forward iterator pointing after the last vectorized store and erase
20553+
// all stores before it so we don't try to vectorize them again.
20554+
DistToInstMap::iterator VectorizedStoresEnd = LastVectorizedStore.base();
20555+
Instrs.erase(Instrs.begin(), VectorizedStoresEnd);
2056120556
}
2056220557

2056320558
private:

0 commit comments

Comments
 (0)