[Mlir-commits] [mlir] [mlir][Affine][NFC] Amortize cost of block op index lookups (PR #156027)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Fri Sep 12 07:47:31 PDT 2025


https://github.com/ftynse requested changes to this pull request.

I don't think this cache is effective. The cache is re-created every time we enter the `findInstPosition` function. The function traverses ancestor blocks for the given op once and then exists. There doesn't seem to be any reuse. FWIW, this is worse because the logic always goes until the end of each block and creates data structures, as opposed to going only until the (ancestor of the) op in question.

I suspect the comment may have either referred to using the cached position of the operation (https://github.com/llvm/llvm-project/blob/50f539c858aa4d7e71d9b5d5d7da7c30ffaf4bea/mlir/include/mlir/IR/Operation.h#L1047) that is used by `isBeforeInBlock`, or a larger overhaul of the algorithm that doesn't need numeric positions of an operation in the block.

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


More information about the Mlir-commits mailing list