|
@@ -688,9 +688,7 @@ Value *SimplifyCFGOpt::isValueEqualityComparison(TerminatorInst *TI) {
|
|
if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
|
|
if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
|
|
// Do not permit merging of large switch instructions into their
|
|
// Do not permit merging of large switch instructions into their
|
|
// predecessors unless there is only one predecessor.
|
|
// predecessors unless there is only one predecessor.
|
|
- if (SI->getNumSuccessors() * std::distance(pred_begin(SI->getParent()),
|
|
|
|
- pred_end(SI->getParent())) <=
|
|
|
|
- 128)
|
|
|
|
|
|
+ if (SI->getNumSuccessors() * pred_size(SI->getParent()) <= 128)
|
|
CV = SI->getCondition();
|
|
CV = SI->getCondition();
|
|
} else if (BranchInst *BI = dyn_cast<BranchInst>(TI))
|
|
} else if (BranchInst *BI = dyn_cast<BranchInst>(TI))
|
|
if (BI->isConditional() && BI->getCondition()->hasOneUse())
|
|
if (BI->isConditional() && BI->getCondition()->hasOneUse())
|
|
@@ -2871,7 +2869,7 @@ static Value *ensureValueAvailableInSuccessor(Value *V, BasicBlock *BB,
|
|
if (!AlternativeV)
|
|
if (!AlternativeV)
|
|
break;
|
|
break;
|
|
|
|
|
|
- assert(std::distance(pred_begin(Succ), pred_end(Succ)) == 2);
|
|
|
|
|
|
+ assert(pred_size(Succ) == 2);
|
|
auto PredI = pred_begin(Succ);
|
|
auto PredI = pred_begin(Succ);
|
|
BasicBlock *OtherPredBB = *PredI == BB ? *++PredI : *PredI;
|
|
BasicBlock *OtherPredBB = *PredI == BB ? *++PredI : *PredI;
|
|
if (PHI->getIncomingValueForBlock(OtherPredBB) == AlternativeV)
|
|
if (PHI->getIncomingValueForBlock(OtherPredBB) == AlternativeV)
|
|
@@ -5752,7 +5750,7 @@ bool SimplifyCFGOpt::SimplifyUncondBranch(BranchInst *BI,
|
|
// backedge, so we can eliminate BB.
|
|
// backedge, so we can eliminate BB.
|
|
bool NeedCanonicalLoop =
|
|
bool NeedCanonicalLoop =
|
|
Options.NeedCanonicalLoop &&
|
|
Options.NeedCanonicalLoop &&
|
|
- (LoopHeaders && std::distance(pred_begin(BB), pred_end(BB)) > 1 &&
|
|
|
|
|
|
+ (LoopHeaders && pred_size(BB) > 1 &&
|
|
(LoopHeaders->count(BB) || LoopHeaders->count(Succ)));
|
|
(LoopHeaders->count(BB) || LoopHeaders->count(Succ)));
|
|
BasicBlock::iterator I = BB->getFirstNonPHIOrDbg()->getIterator();
|
|
BasicBlock::iterator I = BB->getFirstNonPHIOrDbg()->getIterator();
|
|
if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
|
|
if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
|