[PATCH] D143945: [AMDGPU] Add legalization case for PTR_ADD on buffer pointers

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 17 01:44:40 PST 2023


foad added a comment.

In D143945#4133628 <https://reviews.llvm.org/D143945#4133628>, @krzysz00 wrote:

> I'm not convinced you need to store the offset in the actual value of the pointer itself. That is, because addres space 7 is non-integral, the only operations that can modify the address a buffer descriptor points to (uhlees the user really wants to do weird things) are GEPs.
>
> This means that, to get the offset argument to the load operation, all we have to do is trace through the G_PTR_ADD operations and add those together until we reach a G_PTR_ADD input that didn't come from a GEP

That doesn't work for a couple of reasons. First the G_PTR_ADDs could be in a loop or other complex control flow, so you can't just statically trace them back through the program. Second there are other things you can do with arbitrary pointers in IR that the backend needs to be able to implement: you can store them to memory and load them later, you can pass them into and out of function calls, you can use them in `phi` and `select` instructions, and so on.

> (ok, there is the complexity that we'd need to replicate comdjtiinaks if we really wanted to do this trace right)

Good point, I'd forgotten about the comdjtiinaks :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143945/new/

https://reviews.llvm.org/D143945



More information about the llvm-commits mailing list