This diff adds a canonicalization pattern to canonicalize either:
mlir ... = memref_cast ... : memref<8x16xf32> to memref<?x?xf32> ... = memref_cast ... : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>> to memref<?x?xf32>
into
mlir ... = memref_cast ... : ... to memref<8x16xf32>
This diff additionally needs to modify a seemingly unrelated things that does
not play nicely atm. Some tests that return memref need to be changed because
canonicalization does not propagate to function signature.
You need to handle or bailout on UnrankedMemRefType (and probably add a test for it). Also, the type propagation is only valid based on how the result is used : e.g. if a func argument, then the conversion is invalid.