[llvm-dev] Replacing ptrtoint+inttoptr with addrspacecast
Cashman, David via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 15 11:34:51 PDT 2019
Given a ptrtoint followed by inttoptr:
%tmp = ptrtoint i16 addrspace(4)* %a to i32
%b = inttoptr i32 %tmp to i8*
InstCombine will normally collapse them to a bitcast (or no-op, if the src and dst pointer types are the same). But if the pointers are in different address spaces, as shown above, it won't, due to the following code in Instructions.cpp:
// Cannot simplify if address spaces are different!
if (SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace())
return 0;
Is this correct? Given that the instructions above are effectively casting the pointer between two address spaces, can/should InstCombine replace the code above with an addrspacecast? Is there something in the LLVM language spec that makes it illegal or undesirable?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190715/586664c2/attachment.html>
More information about the llvm-dev
mailing list