[PATCH] D14829: [SLP] Vectorize gather-like idioms ending at non-consecutive loads.

Ayal Zaks via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 2 23:53:38 PST 2016


Ayal added a subscriber: Ayal.
Ayal added a comment.

It may be better to start from GEPs rather than loads, collecting single-varying-index-GEPs grouped by same-base-pointer that appear in same basic block. That would work for scatters as well as gathers (and a mix ;-), and for other potential users.

If a pair of addresses are consecutive, indeed it would probably be futile to try and vectorize their index computation, because one can be computed from the other rather than independently. But (1) this holds more generally for any simple stride; and (2) it's enough to refrain from treating this pair, why abort all related candidates. Adding "sum += g[2*i]+g[2*i+1];" to your example throws it off needlessly.

+some typos.


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:416
@@ +415,3 @@
+  /// \return The vector element size in bits to use when vectorizing the
+  /// epression tree ending at \p V. This method is used by the vectorizer to
+  /// calculate vectorization factors.
----------------
e[x]pression


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:3158-3159
@@ +3157,4 @@
+  // that feed it. The type of the loaded value may indicate a more suitable
+  // width than V's type. We want to base the vector element size on the width
+  // of memory operations where possible.
+  SmallVector<Instruction *, 16> Worklist;
----------------
>We want to base the vector element size on the width of memory operations where possible.

This deserves a comment at the outset, namely that the vector element size is derived from the largest size stored to or loaded from memory (following Adam's comment).

================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:3363
@@ +3362,3 @@
+
+  /// The store instructions in a basic block organized by base pointer.
+  LoadListMap LoadRefs;
----------------
store >> load

================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:3505
@@ -3413,4 +3504,3 @@
 
-unsigned SLPVectorizer::collectStores(BasicBlock *BB, BoUpSLP &R) {
-  unsigned count = 0;
+  // Inialize the collection.
   StoreRefs.clear();
----------------
typo


http://reviews.llvm.org/D14829





More information about the llvm-commits mailing list