[Mlir-commits] [mlir] [mlir][memref] Simplify memref.copy canonicalization (PR #149506)
Krzysztof Drewniak
llvmlistbot at llvm.org
Fri Jul 18 10:44:18 PDT 2025
================
@@ -797,22 +752,28 @@ struct FoldEmptyCopy final : public OpRewritePattern<CopyOp> {
void CopyOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) {
- results.add<FoldCopyOfCast, FoldEmptyCopy, FoldSelfCopy>(context);
+ results.add<FoldEmptyCopy, FoldSelfCopy>(context);
}
-LogicalResult CopyOp::fold(FoldAdaptor adaptor,
- SmallVectorImpl<OpFoldResult> &results) {
- /// copy(memrefcast) -> copy
- bool folded = false;
- Operation *op = *this;
+/// If the source/target of a CopyOp is a CastOp that does not modify the shape
+/// and element type, the cast can be skipped. Such CastOps only cast the layout
+/// of the type.
+LogicalResult FoldCopyOfCast(CopyOp op) {
----------------
krzysz00 wrote:
Nit: this should have a `static` on it
https://github.com/llvm/llvm-project/pull/149506
More information about the Mlir-commits
mailing list