Newly allocated buffers do not have a layout map. Bufferization patterns can add a fully dynamic layout map via casting. This should be done only if the layout map is actually needed and not by default on every allocation.
When bufferizing scf.for ops, such layout maps may actually be needed. E.g., after bufferizing an scf.for loop:
scf.for ... -> memref<?xf32, #map> { // We alloc because of an out-of-place bufferization. %0 = memref.alloc : memref<?xf32> // Here we actually need a cast. scf.yield %0 : memref<?xf32> }
Depends On D123321