[Mlir-commits] [mlir] [mlir][linalg] Add folder for `linalg.index` (PR #136640)

Jakub Kuderski llvmlistbot at llvm.org
Mon Apr 21 18:52:24 PDT 2025


================
@@ -2283,6 +2283,35 @@ LogicalResult IndexOp::verify() {
   return success();
 }
 
+OpFoldResult IndexOp::fold(FoldAdaptor adaptor) {
+  auto linalgOp = cast<LinalgOp>((*this)->getParentOp());
+  int64_t flatDimPos =
+      cast<AffineDimExpr>(linalgOp.getShapesToLoopsMap().getResult(getDim()))
----------------
kuhar wrote:

Thanks, this simplifies the code a lot

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


More information about the Mlir-commits mailing list