[Mlir-commits] [mlir] Remove Pure attribute from Linalg::IndexOp. (PR #68894)
Mehdi Amini
llvmlistbot at llvm.org
Fri Nov 28 01:26:05 PST 2025
joker-eph wrote:
> I don't see why linalg.index should not be pure. It has no side-effecting semantics.
We had this discussion a few years ago, everything is already explained above in this issue!!
In the current design of linalg.index there must be a side effect: a pure operation always return value computed from its arguments (i.e. a constant when there is no argument).
To model the transfer of information from the enclosing linalg.generic to the linalg.index operation, you need a "channel" so either:
- There is a hidden resource used to communicated the information: linalg.generic creates/write this resource and linalg.index reads from it (hence it isn't pure).
- There is a SSA value carrying this state (can we get back something inspired by the linalg.indexed_generic design with a block argument?), in which case linalg.index could be pure.
There is no other option within the design of MLIR today, I floated [above](https://github.com/llvm/llvm-project/pull/68894#issuecomment-1849323082) that we could explore a different kind of model by introducing a concept of "region instance" to make the effect "local" there, but that requires some very careful design work. In the meantime: linag.index in its current form must have a side-effect.
https://github.com/llvm/llvm-project/pull/68894
More information about the Mlir-commits
mailing list