[llvm] [GlobalISel] Constant-fold G_PTR_ADD with different type sizes (PR #81473)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 05:08:47 PST 2024


Pierre-vh wrote:

> Is constant-folding G_PTR_ADD target-independent? Does it depend on the address space? Do AMDGPU and AArch64 do the same for _all_ address spaces?

Very good question, and I believe the answer is yes - it depends on the AS. It's safe for most address spaces but in the case that the AS is special (e.g. fat pointer) it's probably not safe. I think we're missing a hook somewhere to ask the target if it's safe to trivially fold G_PTR_ADD as a `G_ADD`. cc @arsenm ?
That or I'm misunderstanding how G_PTR_ADD is supposed to work.




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


More information about the llvm-commits mailing list