[PATCH] D136757: [SLP] Extend reordering data of tree entry to support PHI nodes
    Alexey Bataev via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Oct 31 05:55:46 PDT 2022
    
    
  
ABataev added inline comments.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3826
     return TE.ReorderIndices;
+  if (TE.State == TreeEntry::Vectorize && TE.getOpcode() == Instruction::PHI) {
+    auto PHICompare = [](llvm::Value *V1, llvm::Value *V2) {
----------------
I believe this can be used not only for PHIs, but for other instructions too
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3862-3863
+    };
+    if (!TE.ReorderIndices.empty())
+      return TE.ReorderIndices;
+    DenseMap<Value *, unsigned> PhiToId;
----------------
I believe this can be combined with the buildvector order but we can skip it for now.
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3871
+    }
+    llvm::sort(Phis, PHICompare);
+    for (unsigned Id = 0, Sz = Phis.size(); Id < Sz; ++Id)
----------------
Better to use stable_sort
================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4029
         GathersToOrders.try_emplace(TE.get(), *CurrentOrder);
+      if (TE->State == TreeEntry::Vectorize && isa<PHINode>(TE->getMainOp()))
+        PhisToOrders.try_emplace(TE.get(), *CurrentOrder);
----------------
`&& TE->getOpcode() == Instruction::PHI`, but I think better to implement it for all possible instructions here
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136757/new/
https://reviews.llvm.org/D136757
    
    
More information about the llvm-commits
mailing list