MaheshRavishankar wrote: I am not sure that removing the `memref.dim` canonicalization here is the right answer. The canonicalization itself seems fine apart from it inserting operation after the op. https://github.com/llvm/llvm-project/pull/84225