[Mlir-commits] [mlir] [MLIR][Affine] Fix memref replacement in affine-data-copy-generate (PR #139016)

Uday Bondhugula llvmlistbot at llvm.org
Thu May 29 22:50:02 PDT 2025


================
@@ -447,3 +447,51 @@ func.func @memref_def_inside(%arg0: index) {
   // LIMITED-MEM-NEXT:   memref.dealloc %{{.*}} : memref<1xf32>
   return
 }
+
+// Test with uses across multiple blocks.
+
+memref.global "private" constant @__constant_1x2x1xi32_1 : memref<1x2x1xi32> = dense<0> {alignment = 64 : i64}
+
+// CHECK-LABEL: func @multiple_blocks
+func.func @multiple_blocks(%arg0: index) -> memref<1x2x1xi32> {
+  %c1_i32 = arith.constant 1 : i32
+  %c3_i32 = arith.constant 3 : i32
+  %0 = memref.get_global @__constant_1x2x1xi32_1 : memref<1x2x1xi32>
+  %alloc = memref.alloc() {alignment = 64 : i64} : memref<1x2x1xi32>
+  memref.copy %0, %alloc : memref<1x2x1xi32> to memref<1x2x1xi32>
+  cf.br ^bb1(%alloc : memref<1x2x1xi32>)
+^bb1(%1: memref<1x2x1xi32>):  // 2 preds: ^bb0, ^bb2
+// CHECK: ^bb1(%[[MEM:.*]]: memref<1x2x1xi32>):
+  %alloc_0 = memref.alloc() {alignment = 64 : i64} : memref<1x2x1xi1>
+  // CHECK: %[[BUF:.*]] = memref.alloc() : memref<1x2x1xi32>
----------------
bondhugula wrote:

The RUN command above specifies '0' as the memory space for the fast buffer as well - for e.g. for the typical case of CPUs where the buffer is expected to live in cache.

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


More information about the Mlir-commits mailing list