[Mlir-commits] [mlir] [mlir][linalg] Fix rank-reducing insert_slice vectorization writing to wrong dims (PR #226490)

Dhairyashil R G llvmlistbot at llvm.org
Sun Oct 4 09:09:58 PDT 2026


================
@@ -0,0 +1,53 @@
+// DEFINE: %{entry_point} = main
+// DEFINE: %{lower} = -one-shot-bufferize=bufferize-function-boundaries \
+// DEFINE:   -buffer-deallocation-pipeline -convert-linalg-to-loops \
+// DEFINE:   -convert-vector-to-scf -lower-affine
+// DEFINE: %{run} = mlir-runner -e %{entry_point} -entry-point-result=void \
+// DEFINE:    -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils
+
+/// End-to-end test for vectorizing a rank-reducing tensor.insert_slice. Both
+/// runs use the same lowering and must print the same thing.
+
+/// Reference: the schedule is erased, so the insert_slice is not vectorized.
+// RUN: mlir-opt %s -test-transform-dialect-erase-schedule %{lower} \
+// RUN:   | mlir-opt -test-lower-to-llvm | %{run} | FileCheck %s
+
+/// Vectorized.
+// RUN: mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule %{lower} \
+// RUN:   | mlir-opt -test-lower-to-llvm | %{run} | FileCheck %s
+
+func.func @main() {
+  %pad = arith.constant 0 : i32
+  %src = arith.constant dense<[1, 2, 3, 4, 5]> : tensor<5xi32>
+  %empty = tensor.empty() : tensor<5x3xi32>
+  %init = linalg.fill ins(%pad : i32) outs(%empty : tensor<5x3xi32>) -> tensor<5x3xi32>
+
+  /// Dim 1 of the slice is dropped, so the source's only dim corresponds to
+  /// dim 0 of the result. Writing along dim 1 instead keeps just the first
+  /// element.
----------------
dhairyashilRG wrote:

Removed.

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


More information about the Mlir-commits mailing list