[PATCH] D147025: [InstCombine] Teach alloca replacement to handle `addrspacecast`

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 11:19:17 PDT 2023


hliao added a comment.

In D147025#4233724 <https://reviews.llvm.org/D147025#4233724>, @nikic wrote:

> As far as I can tell, your motivating test cases do not require the TTI hook. They only need trivial address space casts (to the same address space).
>
> Using TTI inside InstCombine is forbidden as a matter of policy. You would need to make an argument for why this exception should be allowed (it would probably go along the lines of "this should really be part of data layout"), so I would recommend to only handle this trivial case first and bypass the TTI issue.

Yes, that specific test doesn't need a TTI hook to enhance the instcombine. But, that TTI hook is provided to handle other valid address spaces per target. For example, on most GPU devices, the cast from a global pointer to a generic pointer is valid but not in the reverse direction. However, that needs to change the target code and target-specific test. I do not own any target code to test that hook further. If required, I could modify AMDGPU as an example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147025



More information about the llvm-commits mailing list