[llvm] [SandboxVectorizer] Add MemSeed bundle types (PR #111584)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 15:38:02 PDT 2024


================
@@ -123,5 +123,44 @@ class SeedBundle {
   }
 #endif // NDEBUG
 };
+
+/// Specialization of SeedBundle for memory access instructions. Keeps
+/// seeds sorted in ascending memory order, which is convenient for slicing
+/// these bundles into vectorizable groups.
+template <typename LoadOrStoreT> class MemSeedBundle : public SeedBundle {
+public:
+  explicit MemSeedBundle(SmallVector<Instruction *> &&SV, ScalarEvolution &SE)
+      : SeedBundle(std::move(SV)) {
+    static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
+                      std::is_same<LoadOrStoreT, StoreInst>::value,
+                  "Expected LoadInst or StoreInst!");
+    assert(all_of(Seeds, [](auto *S) { return isa<LoadOrStoreT>(S); }) &&
+           "Expected Load or Store instructions!");
+    auto Cmp = [&SE](Instruction *I0, Instruction *I1) {
+      return Utils::atLowerAddress(cast<LoadOrStoreT>(I0),
+                                   cast<LoadOrStoreT>(I1), SE);
+    };
+    std::sort(Seeds.begin(), Seeds.end(), Cmp);
+  }
+  explicit MemSeedBundle(LoadOrStoreT *MemI) : SeedBundle(MemI) {
+    static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
----------------
Sterling-Augustine wrote:

There are two constructors. One for a single instruction, one for a list. Not sure which will end up being more used.

https://github.com/llvm/llvm-project/pull/111584


More information about the llvm-commits mailing list