diff --git a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp @@ -39,7 +39,7 @@ return false; } else { auto opResult = cast(val); - if (!domInfo.dominates(opResult.getOwner(), insertionPoint)) + if (!domInfo.properlyDominates(opResult.getOwner(), insertionPoint)) return false; } } diff --git a/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir b/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir --- a/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir +++ b/mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir @@ -259,3 +259,17 @@ } func.return %28 : tensor } + +// ----- + +// CHECK-LABEL: func.func @regression_multiple_insertion_points( +// CHECK-NOT: memref.alloc +func.func @regression_multiple_insertion_points(%t1: tensor) -> tensor { + %empty = tensor.empty() : tensor<2x5xf32> + %f0 = arith.constant 5.5 : f32 + %0 = "test.foo"() : () -> (index) + %1 = "test.bar"() : () -> (index) + %filled = linalg.fill ins(%f0 : f32) outs(%empty : tensor<2x5xf32>) -> tensor<2x5xf32> + %2 = tensor.insert_slice %filled into %t1 [%0, %1] [2, 5] [1, 1] : tensor<2x5xf32> into tensor + return %2 : tensor +}