How to remove unnecessary memref after buffer-results-to-out-params

@matthias-springer
Is there any existing transfroms to remove unnecessary memref produced by --buffer-results-to-out-params --buffer-deallocation?

Here is a small case demonstrating the problem:
// 0: Starting with this:
#map = affine_map<(d0) → (d0)>
module {
func.func @test(%arg0: memref<10xf32>) → memref<10xf32> {
%c2 = arith.constant 2.0 : f32
%alloc = memref.alloc() {alignment = 64 : i64} : memref<10xf32>
linalg.generic {indexing_maps = [#map, #map], iterator_types = [“parallel”]} ins(%arg0 : memref<10xf32>) outs(%alloc: memref<10xf32>) {
^bb0(%in: f32, %out: f32):
%out2 = arith.mulf %in, %c2 : f32
linalg.yield %out2 : f32
}
return %alloc : memref<10xf32>
}
}

// 1: With --buffer-results-to-out-params --buffer-deallocation it becomes this:
#map = affine_map<(d0) → (d0)>
module {
func.func @test(%arg0: memref<10xf32>, %arg1: memref<10xf32>) {
%cst = arith.constant 2.000000e+00 : f32
%alloc = memref.alloc() {alignment = 64 : i64} : memref<10xf32>
linalg.generic {indexing_maps = [#map, #map], iterator_types = [“parallel”]} ins(%arg0 : memref<10xf32>) outs(%alloc : memref<10xf32>) {
^bb0(%in: f32, %out: f32):
%0 = arith.mulf %in, %cst : f32
linalg.yield %0 : f32
}
memref.copy %alloc, %arg1 : memref<10xf32> to memref<10xf32>
memref.dealloc %alloc : memref<10xf32>
return
}
}

// Notice the temp memref %alloc introduces unnecessary
// overhead, which naturally should be eliminated to this:
#map = affine_map<(d0) → (d0)>
module {
func.func @test(%arg0: memref<10xf32>, %arg1: memref<10xf32>) {
%cst = arith.constant 2.000000e+00 : f32
linalg.generic {indexing_maps = [#map, #map], iterator_types = [“parallel”]} ins(%arg0 : memref<10xf32>) outs(%arg1 : memref<10xf32>) {
^bb0(%in: f32, %out: f32):
%0 = arith.mulf %in, %cst : f32
linalg.yield %0 : f32
}
return
}
}

But I could not find any existing transforms that can achieve the last step, which I would expect a very useful clean up and important for performance. Can someone please point me to the right direction? Or it is a nice missing pass to be contributed?