[PATCH] D136201: [InstCombine] Handle PHI nodes when eliminating constant memcpy

Anshil Gandhi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 10:40:45 PST 2022


gandhi21299 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:335-336
+          NewTy->getPointerAddressSpace()) {
+        V = AddrSpaceCastInst::CreatePointerBitCastOrAddrSpaceCast(
+            V, NewTy, V->getName(), NewPHI);
+        PtrCastInserted = true;
----------------
arsenm wrote:
> gandhi21299 wrote:
> > arsenm wrote:
> > > In general InstCombine can't introduce a new address space cast when one didn't exist in the first place 
> > If an incoming value is eligible to be replaced with a pointer from a different addrspace, other incoming values likely do not belong to the addrspace. This makes addrspacecast unavoidable.
> Right, so I'm saying that would just make this illegal and you need to check the address spaces match. Is there a situation where we would want this to happen, that also isn't possible after InferAddressSpaces?
The function @addrspace_cast_remove_alloca in the test I have attached addresses this issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136201



More information about the llvm-commits mailing list