[Mlir-commits] [mlir] [mlir] Fold memref.cast static-to-dynamic to memref.expand_shape (PR #170037)
Matthias Springer
llvmlistbot at llvm.org
Mon Dec 1 01:04:14 PST 2025
================
@@ -2504,11 +2504,89 @@ LogicalResult ExpandShapeOp::verify() {
return success();
}
+struct ExpandShapeOpMemRefCastFolder : public OpRewritePattern<ExpandShapeOp> {
+public:
+ using OpRewritePattern<ExpandShapeOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(ExpandShapeOp op,
+ PatternRewriter &rewriter) const override {
+ auto cast = op.getSrc().getDefiningOp<CastOp>();
+ if (!cast)
+ return failure();
+
+ if (!CastOp::canFoldIntoConsumerOp(cast))
+ return failure();
+
+ auto originalOutputShape = op.getMixedOutputShape();
----------------
matthias-springer wrote:
Can you spell out the type here and for `newOutputShape`?
https://github.com/llvm/llvm-project/pull/170037
More information about the Mlir-commits
mailing list