[llvm] r309284 - [SLP] Outline code for the check that instruction users are part of
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 08:48:44 PDT 2017
Author: abataev
Date: Thu Jul 27 08:48:44 2017
New Revision: 309284
URL: http://llvm.org/viewvc/llvm-project?rev=309284&view=rev
Log:
[SLP] Outline code for the check that instruction users are part of
vectorization tree, NFC.
Modified:
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=309284&r1=309283&r2=309284&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Thu Jul 27 08:48:44 2017
@@ -416,6 +416,9 @@ public:
private:
struct TreeEntry;
+ /// Checks if all users of \p I are the part of the vectorization tree.
+ bool areAllUsersVectorized(Instruction *I) const;
+
/// \returns the cost of the vectorizable entry.
int getEntryCost(TreeEntry *E);
@@ -1702,6 +1705,13 @@ bool BoUpSLP::canReuseExtract(ArrayRef<V
return true;
}
+bool BoUpSLP::areAllUsersVectorized(Instruction *I) const {
+ return I->hasOneUse() ||
+ std::all_of(I->user_begin(), I->user_end(), [this](User *U) {
+ return ScalarToTreeEntry.count(U) > 0;
+ });
+}
+
int BoUpSLP::getEntryCost(TreeEntry *E) {
ArrayRef<Value*> VL = E->Scalars;
@@ -1742,10 +1752,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
// If all users are going to be vectorized, instruction can be
// considered as dead.
// The same, if have only one user, it will be vectorized for sure.
- if (E->hasOneUse() ||
- std::all_of(E->user_begin(), E->user_end(), [this](User *U) {
- return ScalarToTreeEntry.count(U) > 0;
- }))
+ if (areAllUsersVectorized(E))
// Take credit for instruction that will become dead.
DeadCost +=
TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy, i);
More information about the llvm-commits
mailing list