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

Anshil Gandhi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 23:19:35 PST 2022


gandhi21299 marked 2 inline comments as done.
gandhi21299 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:111
       MemTransferInst *MI = dyn_cast<MemTransferInst>(I);
-      if (!MI)
+      if (!MI || isa<PHINode>(MI->getDest()))
         return false;
----------------
arsenm wrote:
> gandhi21299 wrote:
> > nikic wrote:
> > > This is not sufficient: E.g. consider doing the memcpy to an addrspacecast of the phi or similar. I think what we'd need instead is that set `IsOffset=true` for phi nodes, so we'll recursively reject memcpys into it. Of course we would need a different name than IsOffset in that case. It would more generally indicate that the pointer is not equivalent to the base.
> > @nikic What do you mean by "need a different name"? I could simply emplace_back a pair of the instruction and a true to `ValuesToInspect` vector right?
> I think I'm getting lost in the different revisions of the patch; not sure what this comment is referring to anymore. There isn't anything about phi handling right here?
I had a revision previously where I was tracking PHI nodes seperately, as opposed to `IsOffset`. I replaced it with my changes in `PointerReplacer::collectUsers(..)`.


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