[Mlir-commits] [mlir] [mlir][ptr] Add int_to_ptr && ptr_to_int ops (PR #190527)
lonely eagle
llvmlistbot at llvm.org
Wed Jun 17 08:23:34 PDT 2026
linuxlonelyeagle wrote:
> > > As I mentioned above, LLVM dialect allows int to ptr, and I think this existence indicates that there are still some real-world scenarios that require such an operation.
> >
> >
> > It's not clear that these use-cases justify adding to the ptr dialect though, there are alternative, like keeping these ops in the LLVM dialect (or your custom dialect), outside of the pointer dialect for now.
>
> In PyTorch gou/npu scenarios, int-to-ptr is required. I submitted this PR because I felt that ptr dialect was not comprehensive enough in terms of semantic expression.
Coincidentally, I ran into the exact same issue on triton-shared as well. There are a few points worth discussing here.
First, regarding int_to_ptr and ptr_to_int, I understand they are semantically identical to those in the LLVM dialect. Do we really need them in the ptr dialect? If ptr.constant could be extended to support dynamic cases, it would essentially achieve the same purpose as int_to_ptr.
As for allowing ptr.from_ptr to reconstruct a memref from a pointer without metadata, I actually had the same idea but with an additional concern: the most critical issue is that if someone calls free on a memref value reconstructed via ptr.from_ptr without metadata, it might lead to undefined behavior or errors.
https://github.com/llvm/llvm-project/pull/190527
More information about the Mlir-commits
mailing list