[Mlir-commits] [mlir] [mlir][affine] Add folders for delinearize_index and linearize_index (PR #115766)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Nov 13 09:32:40 PST 2024
================
@@ -4820,11 +4860,39 @@ struct CancelLinearizeOfDelinearizeExact final
return success();
}
};
+
+/// Strip leading zero from affine.linearize_index.
+///
+/// `affine.linearize_index [%c0, ...a] by (%x, ...b)` can be rewritten
+/// to `affine.linearize_index [...a] by (...b)` in all cases.
+struct DropLinearizeLeadingZero final
+ : OpRewritePattern<affine::AffineLinearizeIndexOp> {
+ using OpRewritePattern::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(affine::AffineLinearizeIndexOp op,
+ PatternRewriter &rewriter) const override {
+ Value leadingIdx = op.getMultiIndex().front();
----------------
MaheshRavishankar wrote:
IIUC you should be able to drop any zero-value basis (and the corresponding index) right?
https://github.com/llvm/llvm-project/pull/115766
More information about the Mlir-commits
mailing list