mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 04:32:19 +00:00
use AddPredecessorToBlock in 3 places instead of a manual loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121755 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
73c50a68a7
commit
6de0a28dfb
@ -94,8 +94,6 @@ static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2) {
|
||||
/// ExistPred, an existing predecessor of Succ.
|
||||
static void AddPredecessorToBlock(BasicBlock *Succ, BasicBlock *NewPred,
|
||||
BasicBlock *ExistPred) {
|
||||
assert(std::find(succ_begin(ExistPred), succ_end(ExistPred), Succ) !=
|
||||
succ_end(ExistPred) && "ExistPred is not a predecessor of Succ!");
|
||||
if (!isa<PHINode>(Succ->begin())) return; // Quick exit if nothing to do
|
||||
|
||||
PHINode *PN;
|
||||
@ -1089,12 +1087,9 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, const TargetData *TD) {
|
||||
RealDest->getName()+".critedge",
|
||||
RealDest->getParent(), RealDest);
|
||||
BranchInst::Create(RealDest, EdgeBB);
|
||||
PHINode *PN;
|
||||
for (BasicBlock::iterator BBI = RealDest->begin();
|
||||
(PN = dyn_cast<PHINode>(BBI)); ++BBI) {
|
||||
Value *V = PN->getIncomingValueForBlock(BB);
|
||||
PN->addIncoming(V, EdgeBB);
|
||||
}
|
||||
|
||||
// Update PHI nodes.
|
||||
AddPredecessorToBlock(RealDest, EdgeBB, BB);
|
||||
|
||||
// BB may have instructions that are being threaded over. Clone these
|
||||
// instructions into EdgeBB. We know that there will be no uses of the
|
||||
@ -1674,17 +1669,13 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) {
|
||||
|
||||
// OtherDest may have phi nodes. If so, add an entry from PBI's
|
||||
// block that are identical to the entries for BI's block.
|
||||
PHINode *PN;
|
||||
for (BasicBlock::iterator II = OtherDest->begin();
|
||||
(PN = dyn_cast<PHINode>(II)); ++II) {
|
||||
Value *V = PN->getIncomingValueForBlock(BB);
|
||||
PN->addIncoming(V, PBI->getParent());
|
||||
}
|
||||
AddPredecessorToBlock(OtherDest, PBI->getParent(), BB);
|
||||
|
||||
// We know that the CommonDest already had an edge from PBI to
|
||||
// it. If it has PHIs though, the PHIs may have different
|
||||
// entries for BB and PBI's BB. If so, insert a select to make
|
||||
// them agree.
|
||||
PHINode *PN;
|
||||
for (BasicBlock::iterator II = CommonDest->begin();
|
||||
(PN = dyn_cast<PHINode>(II)); ++II) {
|
||||
Value *BIV = PN->getIncomingValueForBlock(BB);
|
||||
@ -1935,10 +1926,7 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) {
|
||||
|
||||
// If there are PHI nodes in EdgeBB, then we need to add a new entry to them
|
||||
// for the edge we just added.
|
||||
for (BasicBlock::iterator I = EdgeBB->begin(); isa<PHINode>(I); ++I) {
|
||||
PHINode *PN = cast<PHINode>(I);
|
||||
PN->addIncoming(PN->getIncomingValueForBlock(NewBB), BB);
|
||||
}
|
||||
AddPredecessorToBlock(EdgeBB, BB, NewBB);
|
||||
|
||||
DEBUG(dbgs() << " ** 'icmp' chain unhandled condition: " << *ExtraCase
|
||||
<< "\nEXTRABB = " << *BB);
|
||||
|
Loading…
x
Reference in New Issue
Block a user