In this patch, we are adding a copy permutation to the transform.promote op. This option is available when using the new mapping attribute to the transform.promote op. This allows changing the logical view of the data (memref.subview) using memref.transpose without moving the data.
If the copy permutation is given by the user, the result operation will be the generated operation linalg.generic otherwise the original linalg target operation.
isa followed by cast (let alone dyn_cast) is an anti-pattern. dyn_cast itself does the type check and returns null on failure, so something like if (auto subview = dyn_cast<memref::SubViewOp>(op)) should be used instead. If you want to be fancy, you can do