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

Mehdi Amini llvmlistbot at llvm.org
Tue Apr 22 05:58:45 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();
----------------
joker-eph wrote:

```suggestion
  SmallVector<int64_t> loopBounds = linalgOp.getStaticLoopRanges();
```

Nit: Do we need the size here?

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


More information about the Mlir-commits mailing list