forked from OSchip/llvm-project
[llvm] Use BasicBlock::phis() (NFC)
This commit is contained in:
parent
1d0bc05551
commit
9b228f107d
|
@ -440,12 +440,8 @@ BasicBlock *BasicBlock::splitBasicBlockBefore(iterator I, const Twine &BBName) {
|
||||||
void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
|
void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
|
||||||
// N.B. This might not be a complete BasicBlock, so don't assume
|
// N.B. This might not be a complete BasicBlock, so don't assume
|
||||||
// that it ends with a non-phi instruction.
|
// that it ends with a non-phi instruction.
|
||||||
for (iterator II = begin(), IE = end(); II != IE; ++II) {
|
for (PHINode &PN : phis())
|
||||||
PHINode *PN = dyn_cast<PHINode>(II);
|
PN.replaceIncomingBlockWith(Old, New);
|
||||||
if (!PN)
|
|
||||||
break;
|
|
||||||
PN->replaceIncomingBlockWith(Old, New);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,
|
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,
|
||||||
|
|
|
@ -2199,13 +2199,10 @@ CleanupAndExit:
|
||||||
if (ParentL)
|
if (ParentL)
|
||||||
ParentL->addBasicBlockToLoop(NewPreheader, *LF);
|
ParentL->addBasicBlockToLoop(NewPreheader, *LF);
|
||||||
IRBuilder<>(NewPreheader).CreateBr(Header);
|
IRBuilder<>(NewPreheader).CreateBr(Header);
|
||||||
for (auto &In : *Header) {
|
for (PHINode &PN : Header->phis()) {
|
||||||
PHINode *PN = dyn_cast<PHINode>(&In);
|
int bx = PN.getBasicBlockIndex(Preheader);
|
||||||
if (!PN)
|
|
||||||
break;
|
|
||||||
int bx = PN->getBasicBlockIndex(Preheader);
|
|
||||||
if (bx >= 0)
|
if (bx >= 0)
|
||||||
PN->setIncomingBlock(bx, NewPreheader);
|
PN.setIncomingBlock(bx, NewPreheader);
|
||||||
}
|
}
|
||||||
DT->addNewBlock(NewPreheader, Preheader);
|
DT->addNewBlock(NewPreheader, Preheader);
|
||||||
DT->changeImmediateDominator(Header, NewPreheader);
|
DT->changeImmediateDominator(Header, NewPreheader);
|
||||||
|
|
|
@ -483,24 +483,20 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
|
||||||
|
|
||||||
// Prepare for the iteration by collecting any simplified entry or backedge
|
// Prepare for the iteration by collecting any simplified entry or backedge
|
||||||
// inputs.
|
// inputs.
|
||||||
for (Instruction &I : *L->getHeader()) {
|
for (PHINode &PHI : L->getHeader()->phis()) {
|
||||||
auto *PHI = dyn_cast<PHINode>(&I);
|
|
||||||
if (!PHI)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// The loop header PHI nodes must have exactly two input: one from the
|
// The loop header PHI nodes must have exactly two input: one from the
|
||||||
// loop preheader and one from the loop latch.
|
// loop preheader and one from the loop latch.
|
||||||
assert(
|
assert(
|
||||||
PHI->getNumIncomingValues() == 2 &&
|
PHI.getNumIncomingValues() == 2 &&
|
||||||
"Must have an incoming value only for the preheader and the latch.");
|
"Must have an incoming value only for the preheader and the latch.");
|
||||||
|
|
||||||
Value *V = PHI->getIncomingValueForBlock(
|
Value *V = PHI.getIncomingValueForBlock(
|
||||||
Iteration == 0 ? L->getLoopPreheader() : L->getLoopLatch());
|
Iteration == 0 ? L->getLoopPreheader() : L->getLoopLatch());
|
||||||
Constant *C = dyn_cast<Constant>(V);
|
Constant *C = dyn_cast<Constant>(V);
|
||||||
if (Iteration != 0 && !C)
|
if (Iteration != 0 && !C)
|
||||||
C = SimplifiedValues.lookup(V);
|
C = SimplifiedValues.lookup(V);
|
||||||
if (C)
|
if (C)
|
||||||
SimplifiedInputValues.push_back({PHI, C});
|
SimplifiedInputValues.push_back({&PHI, C});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now clear and re-populate the map for the next iteration.
|
// Now clear and re-populate the map for the next iteration.
|
||||||
|
@ -625,12 +621,8 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
|
||||||
BasicBlock *ExitingBB, *ExitBB;
|
BasicBlock *ExitingBB, *ExitBB;
|
||||||
std::tie(ExitingBB, ExitBB) = ExitWorklist.pop_back_val();
|
std::tie(ExitingBB, ExitBB) = ExitWorklist.pop_back_val();
|
||||||
|
|
||||||
for (Instruction &I : *ExitBB) {
|
for (PHINode &PN : ExitBB->phis()) {
|
||||||
auto *PN = dyn_cast<PHINode>(&I);
|
Value *Op = PN.getIncomingValueForBlock(ExitingBB);
|
||||||
if (!PN)
|
|
||||||
break;
|
|
||||||
|
|
||||||
Value *Op = PN->getIncomingValueForBlock(ExitingBB);
|
|
||||||
if (auto *OpI = dyn_cast<Instruction>(Op))
|
if (auto *OpI = dyn_cast<Instruction>(Op))
|
||||||
if (L->contains(OpI))
|
if (L->contains(OpI))
|
||||||
AddCostRecursively(*OpI, TripCount - 1);
|
AddCostRecursively(*OpI, TripCount - 1);
|
||||||
|
|
|
@ -2843,12 +2843,8 @@ static void computeLiveInValues(BasicBlock::reverse_iterator Begin,
|
||||||
|
|
||||||
static void computeLiveOutSeed(BasicBlock *BB, SetVector<Value *> &LiveTmp) {
|
static void computeLiveOutSeed(BasicBlock *BB, SetVector<Value *> &LiveTmp) {
|
||||||
for (BasicBlock *Succ : successors(BB)) {
|
for (BasicBlock *Succ : successors(BB)) {
|
||||||
for (auto &I : *Succ) {
|
for (PHINode &PN : Succ->phis()) {
|
||||||
PHINode *PN = dyn_cast<PHINode>(&I);
|
Value *V = PN.getIncomingValueForBlock(BB);
|
||||||
if (!PN)
|
|
||||||
break;
|
|
||||||
|
|
||||||
Value *V = PN->getIncomingValueForBlock(BB);
|
|
||||||
assert(!isUnhandledGCPointerType(V->getType()) &&
|
assert(!isUnhandledGCPointerType(V->getType()) &&
|
||||||
"support for FCA unimplemented");
|
"support for FCA unimplemented");
|
||||||
if (isHandledGCPointerType(V->getType()) && !isa<Constant>(V))
|
if (isHandledGCPointerType(V->getType()) && !isa<Constant>(V))
|
||||||
|
|
|
@ -657,13 +657,9 @@ static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock,
|
||||||
// edge from this block.
|
// edge from this block.
|
||||||
SmallVector<Value *, 8> UnwindDestPHIValues;
|
SmallVector<Value *, 8> UnwindDestPHIValues;
|
||||||
BasicBlock *InvokeBB = II->getParent();
|
BasicBlock *InvokeBB = II->getParent();
|
||||||
for (Instruction &I : *UnwindDest) {
|
for (PHINode &PHI : UnwindDest->phis())
|
||||||
// Save the value to use for this edge.
|
// Save the value to use for this edge.
|
||||||
PHINode *PHI = dyn_cast<PHINode>(&I);
|
UnwindDestPHIValues.push_back(PHI.getIncomingValueForBlock(InvokeBB));
|
||||||
if (!PHI)
|
|
||||||
break;
|
|
||||||
UnwindDestPHIValues.push_back(PHI->getIncomingValueForBlock(InvokeBB));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add incoming-PHI values to the unwind destination block for the given basic
|
// Add incoming-PHI values to the unwind destination block for the given basic
|
||||||
// block, using the values for the original invoke's source block.
|
// block, using the values for the original invoke's source block.
|
||||||
|
|
|
@ -7531,14 +7531,9 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
|
||||||
|
|
||||||
// Collect the incoming values from the PHIs.
|
// Collect the incoming values from the PHIs.
|
||||||
Incoming.clear();
|
Incoming.clear();
|
||||||
for (Instruction &I : *BB) {
|
for (PHINode &P : BB->phis())
|
||||||
PHINode *P = dyn_cast<PHINode>(&I);
|
if (!VisitedInstrs.count(&P) && !R.isDeleted(&P))
|
||||||
if (!P)
|
Incoming.push_back(&P);
|
||||||
break;
|
|
||||||
|
|
||||||
if (!VisitedInstrs.count(P) && !R.isDeleted(P))
|
|
||||||
Incoming.push_back(P);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort by type.
|
// Sort by type.
|
||||||
llvm::stable_sort(Incoming, PhiTypeSorterFunc);
|
llvm::stable_sort(Incoming, PhiTypeSorterFunc);
|
||||||
|
|
Loading…
Reference in New Issue