[PATCH] D68128: [InstCombine] Fold PHIs with equal incoming pointers

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 04:03:06 PDT 2019


lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1157-1168
+  Instruction *InsertPt = nullptr;
+  if (auto *BaseInst = dyn_cast<Instruction>(Base)) {
+    if (isa<PHINode>(BaseInst)) {
+      BasicBlock *InsertBB = BaseInst->getParent();
+      BasicBlock::iterator InsertPtIter = InsertBB->getFirstInsertionPt();
+      // Make sure the insertion point exists.
+      if (InsertPtIter != InsertBB->end())
----------------
DaniilSuchkov wrote:
> lebedev.ri wrote:
> > I'm not sure if this is correct.
> > I'd expect that we actually need to check to where we can move these geps.
> > 
> Why do you think it's incorrect? Given the offset is constant, this code just looks for an insertion point right after base pointer definition and bails out in case when such point doesn't exist.
> 
> What restrictions did I miss?
Actually, i guess this might be ok,
we don't do anything with the users,
and `gep inbounds` at worst produces `poison`.


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

https://reviews.llvm.org/D68128





More information about the llvm-commits mailing list