[Mlir-commits] [mlir] [mlir] Fix loop-like interface (PR #95817)

Ivan Kulagin llvmlistbot at llvm.org
Mon Jun 17 11:57:07 PDT 2024


ikulagin wrote:

> Was there a fail somewhere? I mean I think you're right but I'm shocked this has never come up before...

Fortunately, the llvm-project codebase uses the buggy methods as follows:
```c++
if (auto loop = dyn_cast<LoopLikeOpInterface>(op)) {
    std::optional<Value> iv = loop.getSingleInductionVar();
    ....
}
```

in this case, the correct implementation of `getLoopInductionVars` will be called inside the `getSingleInductionVar`.
If this method were called on a specific operation, for example, `AffineForOp`, then inside the method `getSingleInductionVar` the default implementation of the `getLoopInductionVars` method would be called, and the `getSingleInductionVar` method will always return `std::nullopt`

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


More information about the Mlir-commits mailing list