1// RUN: mlir-opt -verify-diagnostics -ownership-based-buffer-deallocation \
2// RUN:   --buffer-deallocation-simplification -split-input-file %s | FileCheck %s
3// RUN: mlir-opt -verify-diagnostics -ownership-based-buffer-deallocation=private-function-dynamic-ownership=true -split-input-file %s > /dev/null
4
5// RUN: mlir-opt %s -buffer-deallocation-pipeline --split-input-file > /dev/null
6
7// CHECK-LABEL: func @subview
8func.func @subview(%arg0 : index, %arg1 : index, %arg2 : memref<?x?xf32>) {
9  %0 = memref.alloc() : memref<64x4xf32, strided<[4, 1], offset: 0>>
10  %1 = memref.subview %0[%arg0, %arg1][%arg0, %arg1][%arg0, %arg1] :
11    memref<64x4xf32, strided<[4, 1], offset: 0>>
12  to memref<?x?xf32, strided<[?, ?], offset: ?>>
13  test.copy(%1, %arg2) :
14    (memref<?x?xf32, strided<[?, ?], offset: ?>>, memref<?x?xf32>)
15  return
16}
17
18//      CHECK: %[[ALLOC:.*]] = memref.alloc()
19// CHECK-NEXT: memref.subview
20// CHECK-NEXT: test.copy
21// CHECK-NEXT: bufferization.dealloc (%[[ALLOC]] :
22// CHECK-SAME:   if (%true)
23// CHECK-NEXT: return
24