[Mlir-commits] [mlir] [mlir][x86vector] Wrapping `populateFlattenVectorTransferPatterns` as a transform pass. (PR #178134)

Arun Thangamani llvmlistbot at llvm.org
Tue Jan 27 00:00:52 PST 2026


https://github.com/arun-thmn created https://github.com/llvm/llvm-project/pull/178134

This PR covers the `mlir::vector::populateFlattenVectorTransferPatterns` as a transform pass.

>From a782e6fd890175a999f04e0f135403535c8fe26c Mon Sep 17 00:00:00 2001
From: Arun Thangamani <arun.thangamani at intel.com>
Date: Mon, 26 Jan 2026 23:58:24 -0800
Subject: [PATCH] Wrapping populateFlattenVectorTransferPatterns as a transform
 pass

---
 .../X86Vector/TransformOps/X86VectorTransformOps.td   | 11 +++++++++++
 mlir/include/mlir/Dialect/X86Vector/Transforms.h      |  5 +++++
 .../X86Vector/TransformOps/X86VectorTransformOps.cpp  |  7 +++++++
 3 files changed, 23 insertions(+)

diff --git a/mlir/include/mlir/Dialect/X86Vector/TransformOps/X86VectorTransformOps.td b/mlir/include/mlir/Dialect/X86Vector/TransformOps/X86VectorTransformOps.td
index 891829fca017f..4c953abc125bc 100644
--- a/mlir/include/mlir/Dialect/X86Vector/TransformOps/X86VectorTransformOps.td
+++ b/mlir/include/mlir/Dialect/X86Vector/TransformOps/X86VectorTransformOps.td
@@ -71,6 +71,17 @@ def ApplyShuffleVectorFMAOpsPatternsOp : Op<Transform_Dialect,
   let assemblyFormat = "attr-dict";
 }
 
+def ApplyFlattenVectorTransferOpsPatternsOp : Op<Transform_Dialect,
+    "apply_patterns.x86vector.flatten_vector_transfer_ops",
+    [DeclareOpInterfaceMethods<PatternDescriptorOpInterface>]> {
+  let description = [{
+    Collect patterns to rewrite contiguous row-major vector.transfer_read or 
+    vector.transfer_write operations to a 1D operation.
+  }];
+
+  let assemblyFormat = "attr-dict";
+}
+
 
 #endif // X86VECTOR_TRANSFORM_OPS
 
diff --git a/mlir/include/mlir/Dialect/X86Vector/Transforms.h b/mlir/include/mlir/Dialect/X86Vector/Transforms.h
index aadca92708908..3c73a2e172487 100644
--- a/mlir/include/mlir/Dialect/X86Vector/Transforms.h
+++ b/mlir/include/mlir/Dialect/X86Vector/Transforms.h
@@ -104,6 +104,11 @@ void populateSinkVectorProducerOpsPatterns(RewritePatternSet &patterns);
 // grouped with respect to odd/even packed index.
 void populateShuffleVectorFMAOpsPatterns(RewritePatternSet &patterns);
 
+// Rewrites contiguous row-major vector.transfer_read or vector.transfer_write
+// operations by inserting  a memref.collapse_shape on the source,
+// transforming the operation to use a 1D source.
+void populateFlattenVectorTransferOpsPatterns(RewritePatternSet &patterns);
+
 //===----------------------------------------------------------------------===//
 /// Helpers extracted from:
 ///   - clang/lib/Headers/avxintrin.h
diff --git a/mlir/lib/Dialect/X86Vector/TransformOps/X86VectorTransformOps.cpp b/mlir/lib/Dialect/X86Vector/TransformOps/X86VectorTransformOps.cpp
index c6be69305da50..57b0cfc162b8d 100644
--- a/mlir/lib/Dialect/X86Vector/TransformOps/X86VectorTransformOps.cpp
+++ b/mlir/lib/Dialect/X86Vector/TransformOps/X86VectorTransformOps.cpp
@@ -12,6 +12,7 @@
 #include "mlir/Dialect/Transform/IR/TransformDialect.h"
 #include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"
 #include "mlir/Dialect/Vector/IR/VectorOps.h"
+#include "mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h"
 #include "mlir/Dialect/X86Vector/Transforms.h"
 #include "mlir/Dialect/X86Vector/X86VectorDialect.h"
 
@@ -21,6 +22,7 @@
 using namespace mlir;
 using namespace mlir::x86vector;
 using namespace mlir::transform;
+using namespace mlir::vector;
 
 void mlir::transform::ApplyVectorContractToFMAPatternsOp::populatePatterns(
     RewritePatternSet &patterns) {
@@ -47,6 +49,11 @@ void mlir::transform::ApplyShuffleVectorFMAOpsPatternsOp::populatePatterns(
   x86vector::populateShuffleVectorFMAOpsPatterns(patterns);
 }
 
+void mlir::transform::ApplyFlattenVectorTransferOpsPatternsOp::
+    populatePatterns(RewritePatternSet &patterns) {
+  vector::populateFlattenVectorTransferPatterns(patterns);
+}
+
 //===----------------------------------------------------------------------===//
 // Transform op registration
 //===----------------------------------------------------------------------===//



More information about the Mlir-commits mailing list