llvm-project/mlir/test/Dialect/SCF/one-shot-bufferize-invalid.mlir
Matthias Springer 9d6096c56f [mlir][SCF][bufferize][NFC] Move scf.if buffer type computation to getBufferType
A part of the functionality of `bufferize` is extracted into `getBufferType`. Also, bufferized scf.yields inside scf.if are now created with the correct bufferized type from the get-to.

Differential Revision: https://reviews.llvm.org/D132862
2022-08-30 16:48:10 +02:00

17 lines
681 B
MLIR

// RUN: mlir-opt %s -one-shot-bufferize -split-input-file -verify-diagnostics
func.func @inconsistent_memory_space_scf_if(%c: i1) -> tensor<10xf32> {
// Yielding tensors with different memory spaces. Such IR cannot be
// bufferized.
%0 = bufferization.alloc_tensor() {memory_space = 0 : ui64} : tensor<10xf32>
%1 = bufferization.alloc_tensor() {memory_space = 1 : ui64} : tensor<10xf32>
// expected-error @+1 {{inconsistent memory space on then/else branches}}
%r = scf.if %c -> tensor<10xf32> {
// expected-error @+1 {{failed to bufferize op}}
scf.yield %0 : tensor<10xf32>
} else {
scf.yield %1 : tensor<10xf32>
}
func.return %r : tensor<10xf32>
}