diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 47b9f70b6fa026..c445ee8ae22015 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -5626,18 +5626,12 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) { } return false; }; - SmallDenseMap PhiToId; - SmallVector Phis(TE.Scalars.size()); + OrdersType Phis(TE.Scalars.size()); std::iota(Phis.begin(), Phis.end(), 0); - OrdersType ResOrder(TE.Scalars.size()); - for (unsigned Id = 0, Sz = TE.Scalars.size(); Id < Sz; ++Id) - PhiToId[Id] = Id; stable_sort(Phis, PHICompare); - for (unsigned Id = 0, Sz = Phis.size(); Id < Sz; ++Id) - ResOrder[Id] = PhiToId[Phis[Id]]; - if (isIdentityOrder(ResOrder)) + if (isIdentityOrder(Phis)) return std::nullopt; // No need to reorder. - return std::move(ResOrder); + return std::move(Phis); } if (TE.isGather() && !TE.isAltShuffle() && allSameType(TE.Scalars)) { // TODO: add analysis of other gather nodes with extractelement