1// RUN: mlir-opt %s -one-shot-bufferize="test-analysis-only analysis-heuristic=bottom-up-from-terminators" -split-input-file | FileCheck %s
2
3// CHECK-LABEL: func @simple_test(
4func.func @simple_test(%lb: index, %ub: index, %step: index, %f1: f32, %f2: f32) -> (tensor<5xf32>, tensor<5xf32>) {
5  %c0 = arith.constant 0 : index
6  %p = arith.constant 0.0 : f32
7
8  // Make sure that ops that feed into region terminators bufferize in-place
9  // (if possible).
10  // Note: This test case fails to bufferize with a "top-down" or "bottom-up"
11  // heuristic.
12
13  %0 = tensor.empty() : tensor<5xf32>
14  %1 = scf.for %iv = %lb to %ub step %step iter_args(%t = %0) -> (tensor<5xf32>) {
15    // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "false"]}
16    %2 = linalg.fill ins(%f1 : f32) outs(%t : tensor<5xf32>) -> tensor<5xf32>
17    // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "true"]}
18    %3 = linalg.fill ins(%f2 : f32) outs(%t : tensor<5xf32>) -> tensor<5xf32>
19    %4 = vector.transfer_read %2[%c0], %p : tensor<5xf32>, vector<5xf32>
20    vector.print %4 : vector<5xf32>
21    scf.yield %3 : tensor<5xf32>
22  }
23
24  %5 = tensor.empty() : tensor<5xf32>
25  %6 = scf.for %iv = %lb to %ub step %step iter_args(%t = %0) -> (tensor<5xf32>) {
26    // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "true"]}
27    %7 = linalg.fill ins(%f1 : f32) outs(%t : tensor<5xf32>) -> tensor<5xf32>
28    // CHECK: linalg.fill {__inplace_operands_attr__ = ["none", "false"]}
29    %8 = linalg.fill ins(%f2 : f32) outs(%t : tensor<5xf32>) -> tensor<5xf32>
30    %9 = vector.transfer_read %8[%c0], %p : tensor<5xf32>, vector<5xf32>
31    vector.print %9 : vector<5xf32>
32    scf.yield %7 : tensor<5xf32>
33  }
34
35  return %1, %6 : tensor<5xf32>, tensor<5xf32>
36}
37