[PATCH] D141940: [SLP]Add shuffling of extractelements to avoid extra costs/data movement.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 08:55:24 PST 2023


ABataev added a comment.

In D141940#4104462 <https://reviews.llvm.org/D141940#4104462>, @RKSimon wrote:

> There's a lot going on in this patch - making it really difficult to understand

Yeah, I understand, did everything I could. It is a part of another big patch, which improves previous attempt to vectorize the gathered node with extractelement instructions. Original isFixedVectorShuffle is very limited, this patch introduces new function, which tries to handle more cases.

1. Handles extractelements with vectors of different sizes.
2. If we have the extractelements from more than 2 vectors, it selects 2 vector with the most number of uses in the node.
3. If the number of the extracts from one of the vectors is greater than the extracts from 2 vectors with other vector factors, select permutation of single vector, not the very first pair.

Then it reuses the existing isFixedVectorShuffle to build the shuffle for the best subset of instructions.
If it is not succeeded, just exit (later can be extended to try to analyze some other subsets).



================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:630
+  // Restore unused scalars from mask.
+  for (int I = 0, E = GatheredExtracts.size(); I > E; ++I) {
+    auto *EI = dyn_cast<ExtractElementInst>(VL[I]);
----------------
RKSimon wrote:
> I > E?
Very rare case, missed it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141940/new/

https://reviews.llvm.org/D141940



More information about the llvm-commits mailing list