[Mlir-commits] [mlir] "[mlir][linalg] Fix masking for rank-reducing contiguous extracts" (PR #206637)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jun 29 20:31:12 PDT 2026


https://github.com/LouisLu060211 created https://github.com/llvm/llvm-project/pull/206637

Fix masked vectorization of contiguous tensor.extract when the source tensor rank is smaller than the surrounding loop rank.

The contiguous-load tensor.extract path builds a rank-reducing vector.transfer_read by reading only the trailing source dimensions and broadcasting leading vector dimensions. Previously this path returned the transfer_read unmasked and relied on the generic masking path, which builds a mask over the full linalg iteration space.

That full-rank mask is invalid when the source rank is smaller than the loop rank. For example, a 1-D source read inside a 2-D loop nest can produce a vector.transfer_read with inferred mask type vector<4xi1>, while the generic path wraps it with vector<1x4xi1>.

Mask the contiguous transfer_read in place using a minor-identity masking map over the dimensions actually read. This matches the transfer_read permutation map and preserves the existing full-rank behavior.

Add a regression test covering a masked contiguous tensor.extract from a 1-D source inside a 2-D linalg.generic vectorized with vectorize_nd_extract.

Fixes #206209.
Replaces #206634.

Test:
- llvm-lit -a -vv mlir/test/Dialect/Linalg/transform-op-vectorize.mlir

Assisted-by: Codex

>From 5b9b0099f07797b9d3ca307a7ec8cc8d0642914a Mon Sep 17 00:00:00 2001
From: LouisLu0602 <yaolu0602 at gmail.com>
Date: Tue, 30 Jun 2026 11:29:08 +0800
Subject: [PATCH] fixed changes

---
 mlir/lib/Transforms/RemoveDeadValues.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mlir/lib/Transforms/RemoveDeadValues.cpp b/mlir/lib/Transforms/RemoveDeadValues.cpp
index f0a210a2ededb..703d564a07648 100644
--- a/mlir/lib/Transforms/RemoveDeadValues.cpp
+++ b/mlir/lib/Transforms/RemoveDeadValues.cpp
@@ -820,3 +820,5 @@ void RemoveDeadValues::runOnOperation() {
     signalPassFailure();
   }
 }
+
+



More information about the Mlir-commits mailing list