The previous code was a bit too eager in canonicalizing.
I think this should become a pass instead, so that it can also consider aliases and
remove more clones. Block local aliases would suffice to catch situations like
%931 = memref.reshape %930(%107) : (memref<*xf16>, memref<?xindex>) -> memref<*xf16> %932 = memref.clone %931 : memref<*xf16> to memref<*xf16> memref.dealloc %930 : memref<*xf16>
Hey @dfki-jugr. I debugged this a bit today and here is how far I got. We can either land this as a cleanup or you can fold it into some changes you want to do anyway.
This is a dangerous folding, as it means that a clone can change a memref's type. One then has to take care of this in all patterns that want to drop a clone. I'd rather just keep the casting behavior separate.
This is a unrelated minor bug.