We see in our IR that has addrspacecast before ptrtoint, which requires this optimization. Therefore suggest to add the handling of ptrtoint.
Diff Detail
Event Timeline
We see in our IR that has addrspacecast before ptrtoint, which requires this optimization. Therefore suggest to add the handling of ptrtoint.
inttoptr and ptrtoint should be treated as opaque ones. If needed, they should be handled with target-specific. This pass is definitely not the place to handle them.
This is backwards, inttoptr/ptrtoint are "copies" that may truncate or trivially extend. addrspacecast is the opaque part
Thanks for correcting me. What I really mean is that that "copies" are opaque and you cannot interpret them the same as addrspacecast. They are different in semantics.
What if I add another query in TTI, check if an address space has the same bit-pattern as the flat-address, then handle the ptrtoint with this extra condition?
What is the problem you are really trying to solve? There's already a isNoopAddrspaceCast hook
isNoopAddrspaceCast is what I am looking for. Could I use that in this InferAddressSpace pass to get rid of a NoopAddrSpaceCast that is used by ptrtoint?
Maybe, but I'm wondering why you have noop addrspacecasts in the first place. This seems like a problem you shouldn't have to solve
There's an abandon revision. We also now do recognize certain ptrtoint/inttoptr pairs, although this is somewhat questionable