From: Florian Hahn Date: Sun, 30 Apr 2023 20:10:55 +0000 (+0100) Subject: [LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC) X-Git-Tag: upstream/17.0.6~9930 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a431402fd262ca54a923842148be6cdcef7ab636;p=platform%2Fupstream%2Fllvm.git [LV] Remove loop arg from CM::isCandidateForEpilogueVectorization (NFC) LVP operates on the loop it stores in TheLoop. Use it instead of the argument, to be in line with other member functions. Suggested as independent improvement in D143938. --- diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 6418bba..6affd5a 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1844,10 +1844,9 @@ private: Ops, [this, VF](Value *V) { return this->needsExtract(V, VF); })); } - /// Determines if we have the infrastructure to vectorize loop \p L and its + /// Determines if we have the infrastructure to vectorize the loop and its /// epilogue, assuming the main loop is vectorized by \p VF. - bool isCandidateForEpilogueVectorization(const Loop &L, - const ElementCount VF) const; + bool isCandidateForEpilogueVectorization(const ElementCount VF) const; /// Returns true if epilogue vectorization is considered profitable, and /// false otherwise. @@ -5555,10 +5554,10 @@ VectorizationFactor LoopVectorizationCostModel::selectVectorizationFactor( } bool LoopVectorizationCostModel::isCandidateForEpilogueVectorization( - const Loop &L, ElementCount VF) const { + ElementCount VF) const { // Cross iteration phis such as reductions need special handling and are // currently unsupported. - if (any_of(L.getHeader()->phis(), + if (any_of(TheLoop->getHeader()->phis(), [&](PHINode &Phi) { return Legal->isFixedOrderRecurrence(&Phi); })) return false; @@ -5566,20 +5565,21 @@ bool LoopVectorizationCostModel::isCandidateForEpilogueVectorization( // currently unsupported. for (const auto &Entry : Legal->getInductionVars()) { // Look for uses of the value of the induction at the last iteration. - Value *PostInc = Entry.first->getIncomingValueForBlock(L.getLoopLatch()); + Value *PostInc = + Entry.first->getIncomingValueForBlock(TheLoop->getLoopLatch()); for (User *U : PostInc->users()) - if (!L.contains(cast(U))) + if (!TheLoop->contains(cast(U))) return false; // Look for uses of penultimate value of the induction. for (User *U : Entry.first->users()) - if (!L.contains(cast(U))) + if (!TheLoop->contains(cast(U))) return false; } // Epilogue vectorization code has not been auditted to ensure it handles // non-latch exits properly. It may be fine, but it needs auditted and // tested. - if (L.getExitingBlock() != L.getLoopLatch()) + if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) return false; return true; @@ -5626,7 +5626,7 @@ LoopVectorizationCostModel::selectEpilogueVectorizationFactor( // Not really a cost consideration, but check for unsupported cases here to // simplify the logic. - if (!isCandidateForEpilogueVectorization(*TheLoop, MainLoopVF)) { + if (!isCandidateForEpilogueVectorization(MainLoopVF)) { LLVM_DEBUG(dbgs() << "LEV: Unable to vectorize epilogue because the loop " "is not a supported candidate.\n"); return Result;