[PATCH] D83284: [InstCombine] Improve select -> phi canonicalization: consider more blocks

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 23:35:24 PDT 2020


mkazantsev marked an inline comment as done.
mkazantsev added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2518
+    if (auto *PN = foldSelectToPhiImpl(Sel, I->getParent(), DT, Builder))
+      return PN;
+
----------------
nikic wrote:
> It seems quite likely that some of the parents (or all of them) are going to be the same. Might it make sense to deduplicate?
> 
> ```
> // Collect likely candidates for placing the phi node.
> SmallPtrSet<BasicBlock *, 4> CandidateBlocks;
> CandidateBlocks.insert(Sel.getParent();
> for (Value *V : Sel.operands())
>   if (auto *I = dyn_cast<Instruction>(V))
>     CandidateBlocks.insert(I->getParent());
> 
> for (BasicBlock *BB : CandidateBlocks)
>   if (auto *PN = foldSelectToPhiImpl(Sel, BB, DT, Builder))
>     return PN;
> ```
Agreed.


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

https://reviews.llvm.org/D83284





More information about the llvm-commits mailing list