]> granicus.if.org Git - llvm/commitdiff
[SLP] Outline code for the check that instruction users are part of
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 27 Jul 2017 15:48:44 +0000 (15:48 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 27 Jul 2017 15:48:44 +0000 (15:48 +0000)
vectorization tree, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309284 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Vectorize/SLPVectorizer.cpp

index 3e6f84ae7e0e749bb1d0811638d0a56cef7b9977..9931c78fcbc86f87f94a1101fe97452325810cbc 100644 (file)
@@ -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<Value *> VL, Value *OpValue) const {
   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);