[PATCH] D116312: [SLP]Improve isGatherShuffledEntry to handles shuffles between different length vectors.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 1 07:54:46 PDT 2022


RKSimon added inline comments.
Herald added a subscriber: vporpo.
Herald added a project: All.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5897
     }
-    // No perfect match, just shuffle, so choose the first tree node.
-    Entries.push_back(*UsedTEs.front().begin());
+    // No perfect match, just shuffle, so choose the tree node with min index.
+    Entries.push_back(
----------------
min index? Aren't you finding the max_element here?


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5932
+      Entries.push_back(
+          *std::max_element(UsedTEs.front().begin(), UsedTEs.front().end(),
+                            [](const TreeEntry *TE1, const TreeEntry *TE2) {
----------------
Duplicate code - worth pulling this out as a helper?


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6362
+          std::iota(ResizeMask.begin(), ResizeMask.end(), 0);
+          Vec1 = Builder.CreateShuffleVector(Vec1, ResizeMask);
+          if (auto *I = dyn_cast<Instruction>(Vec1)) {
----------------
We do this often enough - I'm wondering if we just add a helper to IRBuilder that creates an identity shuffle that pads/extracts a source Value to requested #elements size?


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:6394
+        }
+      }
+      Vec = Builder.CreateShuffleVector(Vec1, Vec2, Mask);
----------------
Worth putting all of this inside ShuffleInstructionBuilder ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116312



More information about the llvm-commits mailing list