[Mlir-commits] [mlir] [mlir][linalg] fix indexOp folder to work in genericOp build with createOrFold (PR #137427)

Jakub Kuderski llvmlistbot at llvm.org
Fri Apr 25 18:31:51 PDT 2025


================
@@ -2285,7 +2285,8 @@ LogicalResult IndexOp::verify() {
 
 OpFoldResult IndexOp::fold(FoldAdaptor adaptor) {
   auto linalgOp = dyn_cast_or_null<LinalgOp>((*this)->getParentOp());
-  // Early exit if parent op is not linalgOp.
+  // Early exit if linalg.index does not have a proper parent yet
+  // at this point. (e.g createOrFold in a genericOp::build)
----------------
kuhar wrote:

```suggestion
  // Bail out if `linalg.index` does not have a proper parent yet at this
  // point, e.g., when calling `createOrFold` during IR construction in `genericOp::build`.
```

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


More information about the Mlir-commits mailing list