[PATCH] D136201: [InstCombine] Replace alloca with phi uses

Anshil Gandhi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 13:38:12 PDT 2022


gandhi21299 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:261
+      for (unsigned I = 0; I < PHI->getNumIncomingValues(); ++I)
+        Worklist.insert(cast<Instruction>(PHI->getIncomingValue(I)));
+      Worklist.insert(PHI);
----------------
nikic wrote:
> Why do we need to add the phi incoming values to the worklist? Can't this use the same code as bitcast/GEP?
> 
> Also, I think it would be good to add a test involving a loop phi, because I think as written, this code might go into infinite recursion in that case.
I suppose the incoming values would have already been inserted prior to collecting users of the PHI. Thanks!

A loop test sounds like a great idea!


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