[Mlir-commits] [mlir] [mlir][vector] Add vector.to_elements unrolling (PR #157142)

Andrzej Warzyński llvmlistbot at llvm.org
Wed Sep 10 11:25:12 PDT 2025


================
@@ -808,6 +808,28 @@ struct TestUnrollVectorFromElements
   }
 };
 
+struct TestUnrollVectorToElements
+    : public PassWrapper<TestUnrollVectorToElements,
+                         OperationPass<func::FuncOp>> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestUnrollVectorToElements)
+
+  StringRef getArgument() const final {
+    return "test-unroll-vector-to-elements";
+  }
+  StringRef getDescription() const final {
+    return "Test unrolling patterns for to_elements ops";
+  }
+  void getDependentDialects(DialectRegistry &registry) const override {
+    registry.insert<func::FuncDialect, vector::VectorDialect>();
+  }
+
+  void runOnOperation() override {
+    RewritePatternSet patterns(&getContext());
+    populateVectorToElementsLoweringPatterns(patterns);
+    (void)applyPatternsGreedily(getOperation(), std::move(patterns));
+  }
+};
+
----------------
banach-space wrote:

>  Sorry, I am not familiar with TD as an acronym. 

Transform Dialect :)

> The reason why this test pass was added is to keep the style consistent with https://github.com/llvm/llvm-project/pull/151175 .

Consistency is important 👍🏻 However, note that that PR also added `apply_patterns.vector.unroll_from_elements` TD Op. IMO, we should remove the pass added in https://github.com/llvm/llvm-project/pull/151175 and instead have one TD Op for unrolling `to_elements` and `from_elements`.

>  Happy to add it if needed, but I prefer to maintain the consistency with the vector.from_elements unrolling PR.

Yes, consistency is key. Again, my suggestion is to only have a TD Op for both Ops.

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


More information about the Mlir-commits mailing list