[llvm] 617398e - [SLP] Collect candidate VFs in vector in vectorizeStores (NFC). (#82793)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 12:13:52 PST 2024


Author: Florian Hahn
Date: 2024-03-01T20:13:49Z
New Revision: 617398e5e28665ca49810ff5db684292f4b2eb1f

URL: https://github.com/llvm/llvm-project/commit/617398e5e28665ca49810ff5db684292f4b2eb1f
DIFF: https://github.com/llvm/llvm-project/commit/617398e5e28665ca49810ff5db684292f4b2eb1f.diff

LOG: [SLP] Collect candidate VFs in vector in vectorizeStores (NFC). (#82793)

This is in preparation for
https://github.com/llvm/llvm-project/pull/77790 and makes it easy to add
other, non-power-of-2 VFs for processing.

PR: https://github.com/llvm/llvm-project/pull/82793

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5e487a6b8a5daf..daea3bdce68893 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -14026,10 +14026,17 @@ bool SLPVectorizerPass::vectorizeStores(ArrayRef<StoreInst *> Stores,
         continue;
       }
 
+      unsigned Sz = 1 + Log2_32(MaxVF) - Log2_32(MinVF);
+      SmallVector<unsigned> CandidateVFs(Sz);
       // FIXME: Is division-by-2 the correct step? Should we assert that the
       // register size is a power-of-2?
+      unsigned Size = MaxVF;
+      for_each(CandidateVFs, [&](unsigned &VF) {
+        VF = Size;
+        Size /= 2;
+      });
       unsigned StartIdx = 0;
-      for (unsigned Size = MaxVF; Size >= MinVF; Size /= 2) {
+      for (unsigned Size : CandidateVFs) {
         for (unsigned Cnt = StartIdx, E = Operands.size(); Cnt + Size <= E;) {
           ArrayRef<Value *> Slice = ArrayRef(Operands).slice(Cnt, Size);
           assert(


        


More information about the llvm-commits mailing list