Files
clang-p2996/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-compat.mlir
River Riddle 412b8850f6 [mlir][NFC] Update textual references of func to func.func in Bufferization/Complex/EmitC/CF/Func/GPU tests
The special case parsing of `func` operations is being removed.
2022-04-20 22:17:28 -07:00

32 lines
1.1 KiB
MLIR

// RUN: mlir-opt %s \
// RUN: -one-shot-bufferize="allow-unknown-ops create-deallocs=0" \
// RUN: -split-input-file | \
// RUN: FileCheck %s --check-prefix=CHECK-NODEALLOC
// RUN: mlir-opt %s \
// RUN: -one-shot-bufferize="allow-unknown-ops create-deallocs=0" \
// RUN: -buffer-deallocation | \
// RUN: FileCheck %s --check-prefix=CHECK-BUFFERDEALLOC
// CHECK-NODEALLOC-LABEL: func @out_of_place_bufferization
// CHECK-BUFFERDEALLOC-LABEL: func @out_of_place_bufferization
func.func @out_of_place_bufferization(%t1 : tensor<?xf32>) -> (f32, f32) {
// CHECK-NODEALLOC: memref.alloc
// CHECK-NODEALLOC: memref.copy
// CHECK-NODEALLOC-NOT: memref.dealloc
// CHECK-BUFFERDEALLOC: %[[alloc:.*]] = memref.alloc
// CHECK-BUFFERDEALLOC: memref.copy
// CHECK-BUFFERDEALLOC: memref.dealloc %[[alloc]]
%cst = arith.constant 0.0 : f32
%idx = arith.constant 5 : index
// This bufferizes out-of-place. An allocation + copy will be inserted.
%0 = tensor.insert %cst into %t1[%idx] : tensor<?xf32>
%1 = tensor.extract %t1[%idx] : tensor<?xf32>
%2 = tensor.extract %0[%idx] : tensor<?xf32>
return %1, %2 : f32, f32
}