diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 87de28044b2ae..5ec7b49e37079 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -22140,7 +22140,7 @@ class HorizontalReduction { // Try to regroup reduced values so that it gets more profitable to try to // reduce them. Values are grouped by their value ids, instructions - by // instruction op id and/or alternate op id, plus do extra analysis for - // loads (grouping them by the distabce between pointers) and cmp + // loads (grouping them by the distance between pointers) and cmp // instructions (grouping them by the predicate). SmallMapVector< size_t, SmallMapVector, 2>, @@ -22207,10 +22207,9 @@ class HorizontalReduction { for (auto &PossibleReducedVals : PossibleReducedValsVect) { auto PossibleRedVals = PossibleReducedVals.second.takeVector(); SmallVector> PossibleRedValsVect; - for (auto It = PossibleRedVals.begin(), E = PossibleRedVals.end(); - It != E; ++It) { + for (auto &Slice : PossibleRedVals) { PossibleRedValsVect.emplace_back(); - auto RedValsVect = It->second.takeVector(); + auto RedValsVect = Slice.second.takeVector(); stable_sort(RedValsVect, llvm::less_second()); for (const std::pair &Data : RedValsVect) PossibleRedValsVect.back().append(Data.second, Data.first); @@ -22370,8 +22369,8 @@ class HorizontalReduction { SmallVector Candidates; Candidates.reserve(2 * OrigReducedVals.size()); DenseMap TrackedToOrig(2 * OrigReducedVals.size()); - for (unsigned Cnt = 0, Sz = OrigReducedVals.size(); Cnt < Sz; ++Cnt) { - Value *RdxVal = TrackedVals.at(OrigReducedVals[Cnt]); + for (Value *ReducedVal : OrigReducedVals) { + Value *RdxVal = TrackedVals.at(ReducedVal); // Check if the reduction value was not overriden by the extractelement // instruction because of the vectorization and exclude it, if it is not // compatible with other values. @@ -22382,7 +22381,7 @@ class HorizontalReduction { (S && !Inst)) continue; Candidates.push_back(RdxVal); - TrackedToOrig.try_emplace(RdxVal, OrigReducedVals[Cnt]); + TrackedToOrig.try_emplace(RdxVal, ReducedVal); } bool ShuffledExtracts = false; // Try to handle shuffled extractelements.