[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 02:45:20 PDT 2025


================
@@ -2158,11 +2158,41 @@ struct ReinterpretCastOpExtractStridedMetadataFolder
     return success();
   }
 };
+
+struct ReinterpretCastOpConstantFolder
+    : public OpRewritePattern<ReinterpretCastOp> {
+public:
+  using OpRewritePattern<ReinterpretCastOp>::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(ReinterpretCastOp op,
+                                PatternRewriter &rewriter) const override {
+    unsigned srcStaticCount = llvm::count_if(
----------------
matthias-springer wrote:

Can you add a TODO here that you're counting instead of directly comparing because `getMixedValues` (and therefore `ReinterpretCastOp::getMixed...`) returns IntegerAttrs and `constifyIndexValues` (and therefore `ReinterpretCastOp::getConstifiedMixed...`) returns IndexAttrs?


https://github.com/llvm/llvm-project/pull/163505


More information about the Mlir-commits mailing list