[Mlir-commits] [flang] [mlir] [RFC][mlir] ViewLikeOpInterface method for detecting partial views. (PR #164020)
Razvan Lupusoru
llvmlistbot at llvm.org
Mon Oct 20 11:53:00 PDT 2025
razvanlupusoru wrote:
> I thought a bit more about this, and I think that for aliasing analysis we should only care about the beginning of the input and result buffers. For example, if the initial view is `(ptr1, size1)`, and the resulting view is `(ptr1, size2)`, then we should actually report `MustAlias`. The fact that the `size1` may be bigger than `size2` should not affect the alias analysis.
Interesting - I double-checked against LLVM and its documentation for `MustAlias` does NOT require the objects to be the same size: https://llvm.org/docs/AliasAnalysis.html#must-may-and-no-alias-responses
So I see your point about `MustAlias` being technically valid here.
However, I would like to point out that even LLVM's implementations for alias analysis are not strict about this. For example, a quick search revealed at least one spot where the same base address returns `PartialAlias` if one of the accesses does not cover the whole object:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/BasicAliasAnalysis.cpp#L1858
To me, it makes more sense to return `PartialAlias` when sizes are provably not equivalent, but I think either approach is acceptable as long as it is clearly documented.
Regarding your suggestion to capture all of this in `ViewLikeOpInterface` instead of adding `SubviewLikeOpInterface`: I'm fine with that approach since it still captures the information I currently need with the addition of `isCompleteView`. I'm hoping to use this functionality in OpenACC support to ensure proper device mapping order.
Thank you for your proposal, Slava!
https://github.com/llvm/llvm-project/pull/164020
More information about the Mlir-commits
mailing list