[Mlir-commits] [mlir] [MemRef] Remove redundant elide-rc through load tests (PR #213033)
ioana ghiban
llvmlistbot at llvm.org
Thu Aug 6 08:23:43 PDT 2026
https://github.com/ioghiban updated https://github.com/llvm/llvm-project/pull/213033
>From 2bcb6b87eca32e03b2b463644e6c9cbd797590fb Mon Sep 17 00:00:00 2001
From: Ioana Ghiban <ioana.ghiban at arm.com>
Date: Thu, 30 Jul 2026 16:21:51 +0200
Subject: [PATCH 1/2] [MemRef] Remove redundant elide-rc through load tests
---
.../MemRef/elide-reinterpret-cast.mlir | 146 +++---------------
1 file changed, 24 insertions(+), 122 deletions(-)
diff --git a/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir b/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
index f305de1ccd0d8..269af2dcd6f7e 100644
--- a/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
+++ b/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
@@ -742,56 +742,9 @@ func.func private @collapse_scalar(%src : memref<1x1x1xi64>) {
return
}
-// CHECK-LABEL: func.func private @expand_left_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<999xi64>) {
-func.func private @expand_left_vector(%src : memref<999xi64>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx_1 = arith.constant 0 : index
- %idx_2 = arith.constant 13 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [1, 1, 999], strides: [999, 999, 1]
- : memref<999xi64> to memref<1x1x999xi64>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_2]]] : memref<999xi64>
- %0 = memref.load %reinterpret_cast[%idx_1, %idx_1, %idx_2] : memref<1x1x999xi64>
- return
-}
-
-// CHECK-LABEL: func.func private @expand_left_vector_dynamic_index(
-// CHECK-SAME: %[[I:.*]]: index
-// CHECK-SAME: %[[SRC:.*]]: memref<999xi64>) {
-func.func private @expand_left_vector_dynamic_index(%i : index,
- %src : memref<999xi64>) {
- // CHECK: %[[IDX:.*]] = arith.constant 0 : index
- %idx = arith.constant 0 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [1, 1, 999], strides: [999, 999, 1]
- : memref<999xi64> to memref<1x1x999xi64>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[I]]] : memref<999xi64>
- %0 = memref.load %reinterpret_cast[%idx, %idx, %i] : memref<1x1x999xi64>
- return
-}
-
-// CHECK-LABEL: func.func private @collapse_left_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<1x1x999xi64>) {
-func.func private @collapse_left_vector(%src : memref<1x1x999xi64>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx = arith.constant 13 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999], strides: [1]
- : memref<1x1x999xi64> to memref<999xi64>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_1]], %[[IDX_1]], %[[IDX_2]]] : memref<1x1x999xi64>
- %0 = memref.load %reinterpret_cast[%idx] : memref<999xi64>
- return
-}
-
-// CHECK-LABEL: func.func private @partial_expand_left_vector(
+// CHECK-LABEL: func.func private @expand_vector(
// CHECK-SAME: %[[SRC:.*]]: memref<1x999xf32>) {
-func.func private @partial_expand_left_vector(
+func.func private @expand_vector(
%src : memref<1x999xf32>) {
// CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
@@ -807,9 +760,9 @@ func.func private @partial_expand_left_vector(
return
}
-// CHECK-LABEL: func.func private @partial_collapse_left_vector(
+// CHECK-LABEL: func.func private @collapse_vector(
// CHECK-SAME: %[[SRC:.*]]: memref<1x1x999xf32>) {
-func.func private @partial_collapse_left_vector(
+func.func private @collapse_vector(
%src : memref<1x1x999xf32>) {
// CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
@@ -824,86 +777,35 @@ func.func private @partial_collapse_left_vector(
return
}
-// CHECK-LABEL: func.func private @expand_right_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<999xi64>) {
-func.func private @expand_right_vector(%src : memref<999xi64>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx_1 = arith.constant 0 : index
- %idx_2 = arith.constant 13 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999, 1, 1], strides: [1, 999, 999]
- : memref<999xi64> to memref<999x1x1xi64, strided<[1, 999, 999]>>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_2]]] : memref<999xi64>
- %0 = memref.load %reinterpret_cast[%idx_2, %idx_1, %idx_1] : memref<999x1x1xi64,
- strided<[1, 999, 999]>>
- return
-}
-
-// CHECK-LABEL: func.func private @collapse_right_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<999x1x1xi64>) {
-func.func private @collapse_right_vector(%src : memref<999x1x1xi64>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx = arith.constant 13 : index
+// CHECK-LABEL: func.func private @expand_vector_dynamic_index(
+// CHECK-SAME: %[[I:.*]]: index
+// CHECK-SAME: %[[SRC:.*]]: memref<1x999xi64>) {
+func.func private @expand_vector_dynamic_index(%i : index,
+ %src : memref<1x999xi64>) {
+ // CHECK: %[[IDX:.*]] = arith.constant 0 : index
+ %idx = arith.constant 0 : index
// CHECK-NOT: memref.reinterpret_cast
%reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999], strides: [1]
- : memref<999x1x1xi64> to memref<999xi64>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_2]], %[[IDX_1]], %[[IDX_1]]] : memref<999x1x1xi64>
- %0 = memref.load %reinterpret_cast[%idx] : memref<999xi64>
+ to offset: [0], sizes: [1, 1, 999], strides: [999, 999, 1]
+ : memref<1x999xi64> to memref<1x1x999xi64>
+ // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX]], %[[I]]] : memref<1x999xi64>
+ %0 = memref.load %reinterpret_cast[%idx, %idx, %i] : memref<1x1x999xi64>
return
}
-// CHECK-LABEL: func.func private @collapse_right_vector_dynamic_index(
+// CHECK-LABEL: func.func private @collapse_vector_dynamic_index(
// CHECK-SAME: %[[I:.*]]: index
-// CHECK-SAME: %[[SRC:.*]]: memref<999x1x1xi64>) {
-func.func private @collapse_right_vector_dynamic_index(%i : index,
- %src : memref<999x1x1xi64>) {
+// CHECK-SAME: %[[SRC:.*]]: memref<1x1x999xi64>) {
+func.func private @collapse_vector_dynamic_index(%i : index,
+ %src : memref<1x1x999xi64>) {
// CHECK-DAG: %[[IDX:.*]] = arith.constant 0 : index
+ %idx = arith.constant 0 : index
// CHECK-NOT: memref.reinterpret_cast
%reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999], strides: [1]
- : memref<999x1x1xi64> to memref<999xi64>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[I]], %[[IDX]], %[[IDX]]] : memref<999x1x1xi64>
- %0 = memref.load %reinterpret_cast[%i] : memref<999xi64>
- return
-}
-
-// CHECK-LABEL: func.func private @partial_expand_right_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<999x1xf32>) {
-func.func private @partial_expand_right_vector(
- %src : memref<999x1xf32>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx_1 = arith.constant 0 : index
- %idx_2 = arith.constant 13 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999, 1, 1], strides: [1, 999, 999]
- : memref<999x1xf32> to memref<999x1x1xf32, strided<[1, 999, 999]>>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_2]], %[[IDX_1]]] : memref<999x1xf32>
- %0 = memref.load %reinterpret_cast[%idx_2, %idx_1, %idx_1]
- : memref<999x1x1xf32, strided<[1, 999, 999]>>
- return
-}
-
-// CHECK-LABEL: func.func private @partial_collapse_right_vector(
-// CHECK-SAME: %[[SRC:.*]]: memref<999x1x1xf32>) {
-func.func private @partial_collapse_right_vector(
- %src : memref<999x1x1xf32>) {
- // CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
- // CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
- %idx_1 = arith.constant 0 : index
- %idx_2 = arith.constant 13 : index
- // CHECK-NOT: memref.reinterpret_cast
- %reinterpret_cast = memref.reinterpret_cast %src
- to offset: [0], sizes: [999, 1], strides: [1, 999]
- : memref<999x1x1xf32> to memref<999x1xf32, strided<[1, 999]>>
- // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX_2]], %[[IDX_1]], %[[IDX_1]]] : memref<999x1x1xf32>
- %0 = memref.load %reinterpret_cast[%idx_2, %idx_1] : memref<999x1xf32,
- strided<[1, 999]>>
+ to offset: [0], sizes: [1, 999], strides: [999, 1]
+ : memref<1x1x999xi64> to memref<1x999xi64>
+ // CHECK: %[[LOAD:.*]] = memref.load %[[SRC]][%[[IDX]], %[[IDX]], %[[I]]] : memref<1x1x999xi64>
+ %0 = memref.load %reinterpret_cast[%idx, %i] : memref<1x999xi64>
return
}
>From 6f65495eadee975a2a0e390399ecfddde84cce6f Mon Sep 17 00:00:00 2001
From: Ioana Ghiban <ioana.ghiban at arm.com>
Date: Thu, 6 Aug 2026 17:23:11 +0200
Subject: [PATCH 2/2] Address comments
---
.../Dialect/MemRef/elide-reinterpret-cast.mlir | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir b/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
index 269af2dcd6f7e..3822dd13f006a 100644
--- a/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
+++ b/mlir/test/Dialect/MemRef/elide-reinterpret-cast.mlir
@@ -742,9 +742,10 @@ func.func private @collapse_scalar(%src : memref<1x1x1xi64>) {
return
}
-// CHECK-LABEL: func.func private @expand_vector(
+/// 1x999 is effectively a 1D MemRef
+// CHECK-LABEL: func.func private @expand_1D(
// CHECK-SAME: %[[SRC:.*]]: memref<1x999xf32>) {
-func.func private @expand_vector(
+func.func private @expand_1D(
%src : memref<1x999xf32>) {
// CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
@@ -760,9 +761,9 @@ func.func private @expand_vector(
return
}
-// CHECK-LABEL: func.func private @collapse_vector(
+// CHECK-LABEL: func.func private @collapse_1D(
// CHECK-SAME: %[[SRC:.*]]: memref<1x1x999xf32>) {
-func.func private @collapse_vector(
+func.func private @collapse_1D(
%src : memref<1x1x999xf32>) {
// CHECK-DAG: %[[IDX_1:.*]] = arith.constant 0 : index
// CHECK-DAG: %[[IDX_2:.*]] = arith.constant 13 : index
@@ -777,10 +778,10 @@ func.func private @collapse_vector(
return
}
-// CHECK-LABEL: func.func private @expand_vector_dynamic_index(
+// CHECK-LABEL: func.func private @expand_1D_dynamic_index(
// CHECK-SAME: %[[I:.*]]: index
// CHECK-SAME: %[[SRC:.*]]: memref<1x999xi64>) {
-func.func private @expand_vector_dynamic_index(%i : index,
+func.func private @expand_1D_dynamic_index(%i : index,
%src : memref<1x999xi64>) {
// CHECK: %[[IDX:.*]] = arith.constant 0 : index
%idx = arith.constant 0 : index
@@ -793,10 +794,10 @@ func.func private @expand_vector_dynamic_index(%i : index,
return
}
-// CHECK-LABEL: func.func private @collapse_vector_dynamic_index(
+// CHECK-LABEL: func.func private @collapse_1D_dynamic_index(
// CHECK-SAME: %[[I:.*]]: index
// CHECK-SAME: %[[SRC:.*]]: memref<1x1x999xi64>) {
-func.func private @collapse_vector_dynamic_index(%i : index,
+func.func private @collapse_1D_dynamic_index(%i : index,
%src : memref<1x1x999xi64>) {
// CHECK-DAG: %[[IDX:.*]] = arith.constant 0 : index
%idx = arith.constant 0 : index
More information about the Mlir-commits
mailing list