Skip to content

Commit f935439

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

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
@@ -20902,20 +20902,15 @@ class RelatedStoreInsts {
2090220902

2090320903
/// Remove all stores that have been vectorized from this group.
2090420904
void clearVectorizedStores(const BoUpSLP::ValueSet &VectorizedStores) {
20905-
const auto Begin = Instrs.begin();
20906-
auto NonVectorizedStore = Instrs.end();
20907-
20908-
while (NonVectorizedStore != Begin) {
20909-
const auto Prev = std::prev(NonVectorizedStore);
20910-
unsigned InstrIdx = Prev->second;
20911-
if (VectorizedStores.contains(AllStores[InstrIdx])) {
20912-
// NonVectorizedStore is the last scalar instruction.
20913-
// Erase all stores before it so we don't try to vectorize them again.
20914-
Instrs.erase(Begin, NonVectorizedStore);
20915-
return;
20916-
}
20917-
NonVectorizedStore = Prev;
20918-
}
20905+
DistToInstMap::reverse_iterator LastVectorizedStore = find_if(
20906+
reverse(Instrs), [&](const std::pair<int, unsigned> &DistAndIdx) {
20907+
return VectorizedStores.contains(AllStores[DistAndIdx.second]);
20908+
});
20909+
20910+
// Get a forward iterator pointing after the last vectorized store and erase
20911+
// all stores before it so we don't try to vectorize them again.
20912+
DistToInstMap::iterator VectorizedStoresEnd = LastVectorizedStore.base();
20913+
Instrs.erase(Instrs.begin(), VectorizedStoresEnd);
2091920914
}
2092020915

2092120916
private:

0 commit comments

Comments
 (0)