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

Jakub Kuderski llvmlistbot at llvm.org
Tue Apr 22 08:29:26 PDT 2025


================
@@ -2283,6 +2283,19 @@ LogicalResult IndexOp::verify() {
   return success();
 }
 
+OpFoldResult IndexOp::fold(FoldAdaptor adaptor) {
+  auto linalgOp = cast<LinalgOp>((*this)->getParentOp());
+
+  // Index of unit dims is always 0.
+  SmallVector<int64_t, 4> loopBounds = linalgOp.getStaticLoopRanges();
+  uint64_t dim = getDim();
+  assert(dim < loopBounds.size());
----------------
kuhar wrote:

Done

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


More information about the Mlir-commits mailing list