xref: /llvm-project/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-compat.mlir (revision 6bf043e7433680c6f4e36393734ef83699b30f14)
1// RUN: mlir-opt %s \
2// RUN:     -one-shot-bufferize="allow-unknown-ops" \
3// RUN:     -split-input-file | \
4// RUN: FileCheck %s
5
6// CHECK-LABEL: func @out_of_place_bufferization
7func.func @out_of_place_bufferization(%t1 : tensor<?xf32>) -> (f32, f32) {
8  //     CHECK: memref.alloc
9  //     CHECK: memref.copy
10  // CHECK-NOT: memref.dealloc
11
12  %cst = arith.constant 0.0 : f32
13  %idx = arith.constant 5 : index
14
15  // This bufferizes out-of-place. An allocation + copy will be inserted.
16  %0 = tensor.insert %cst into %t1[%idx] : tensor<?xf32>
17
18  %1 = tensor.extract %t1[%idx] : tensor<?xf32>
19  %2 = tensor.extract %0[%idx] : tensor<?xf32>
20  return %1, %2 : f32, f32
21}
22