[Mlir-commits] [mlir] [mlir][memref] Canonicalize memref.reinterpret_cast when offset/sizes/strides are constants. (PR #163505)
Ming Yan
llvmlistbot at llvm.org
Fri Oct 17 02:05:37 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(),
----------------
NexMing wrote:
Indeed, I have tried these methods. I found that the static values returned by `op.getConstifiedMixedOffset()` are of index type attr, while those from `op.getMixedOffset()` are of i64 type attr. This has been quite confusing for me and has prevented successful comparisons. Any further attempt to compare them would only make the code more complex.
https://github.com/llvm/llvm-project/pull/163505
More information about the Mlir-commits
mailing list