[Mlir-commits] [mlir] [mlir][memref] Canonicalize memref.reinterpret_cast when offset/sizes/strides are constants. (PR #163505)
Matthias Springer
llvmlistbot at llvm.org
Fri Oct 17 01:34:26 PDT 2025
================
@@ -2158,11 +2158,33 @@ struct ReinterpretCastOpExtractStridedMetadataFolder
return success();
}
};
+
+struct ReinterpretCastOpConstantFolder
+ : public OpRewritePattern<ReinterpretCastOp> {
+public:
+ using OpRewritePattern<ReinterpretCastOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(ReinterpretCastOp op,
+ PatternRewriter &rewriter) const override {
+ if (!llvm::any_of(llvm::concat<OpFoldResult>(op.getOffsets(), op.getSizes(),
----------------
matthias-springer wrote:
What I would do: compare `op.getConstifiedMixedOffset()` with `op.getOffsets()` and continue only if the two are different. (Same for sizes/strides.)
https://github.com/llvm/llvm-project/pull/163505
More information about the Mlir-commits
mailing list