[PATCH] D68128: [InstCombine] Fold PHIs with equal incoming pointers
Artur Pilipenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 12:50:32 PST 2019
apilipenko added a comment.
Can we handle the case with inbounds offsets only first and extend with non-inbounds support in a follow up change? This way in the first change you'll not need to change IR interfaces at all.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1163-1164
+ // Make sure the insertion point exists.
+ if (InsertPtIter != InsertBB->end())
+ InsertPt = &*InsertPtIter;
+ } else
----------------
It's ok to insert at the end of BB.
Use `IRBuilder::SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)` for that. After this change there will be no situation when `InsertPt` is available, so the code can structured slightly differently:
```
if (auto *BaseInst = dyn_cast<Instruction>(Base)) {
if (isa<PHINode>(BaseInst))
Builder.SetInsertPoint(BaseInst->getParent(), BaseInst->getParent()->getFirstInsertionPt())
else
Builder.SetInsertPoint(BaseInst->getNextNode());
} else
Builder.SetInsertPoint(...);
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68128/new/
https://reviews.llvm.org/D68128
More information about the llvm-commits
mailing list