[Mlir-commits] [mlir] [mlir][vector] Add InsertInsertToInsert to insert op canonicalize patterns (PR #147045)
lonely eagle
llvmlistbot at llvm.org
Fri Jul 4 05:53:43 PDT 2025
================
@@ -3335,6 +3335,28 @@ class InsertSplatToSplat final : public OpRewritePattern<InsertOp> {
}
};
+/// Pattern to rewrite a InsertOp(InsertOp) to InsertOp.
+class InsertInsertToInsert final : public OpRewritePattern<InsertOp> {
+public:
+ using OpRewritePattern::OpRewritePattern;
+ LogicalResult matchAndRewrite(InsertOp op,
+ PatternRewriter &rewriter) const override {
+ auto destInsert = op.getDest().getDefiningOp<InsertOp>();
+ if (!destInsert)
+ return failure();
+
+ if (!destInsert->hasOneUse())
+ return failure();
+
+ if (op.getMixedPosition() != destInsert.getMixedPosition())
+ return failure();
----------------
linuxlonelyeagle wrote:
I'm not quite sure if I'm understanding you correctly, we could add more tests on the position position, such as the case of introducing dynamic and the case of mixing dynamic and static.
https://github.com/llvm/llvm-project/pull/147045
More information about the Mlir-commits
mailing list