mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 20:12:56 +02:00
SimplifyCFG: Enumerating all predecessors of a BB can be expensive (switches), avoid it if possible.
No functionality change. llvm-svn: 164923
This commit is contained in:
parent
353ea39be4
commit
44f4511b6a
@ -1173,10 +1173,14 @@ static bool SinkThenElseCodeToEnd(BranchInst *BI1) {
|
|||||||
|
|
||||||
// Check that BBEnd has two predecessors and the other predecessor ends with
|
// Check that BBEnd has two predecessors and the other predecessor ends with
|
||||||
// an unconditional branch.
|
// an unconditional branch.
|
||||||
SmallVector<BasicBlock*, 16> Preds(pred_begin(BBEnd), pred_end(BBEnd));
|
pred_iterator PI = pred_begin(BBEnd), PE = pred_end(BBEnd);
|
||||||
if (Preds.size() != 2)
|
BasicBlock *Pred0 = *PI++;
|
||||||
|
if (PI == PE) // Only one predecessor.
|
||||||
return false;
|
return false;
|
||||||
BasicBlock *BB2 = (Preds[0] == BB1) ? Preds[1] : Preds[0];
|
BasicBlock *Pred1 = *PI++;
|
||||||
|
if (PI != PE) // More than two predecessors.
|
||||||
|
return false;
|
||||||
|
BasicBlock *BB2 = (Pred0 == BB1) ? Pred1 : Pred0;
|
||||||
BranchInst *BI2 = dyn_cast<BranchInst>(BB2->getTerminator());
|
BranchInst *BI2 = dyn_cast<BranchInst>(BB2->getTerminator());
|
||||||
if (!BI2 || !BI2->isUnconditional())
|
if (!BI2 || !BI2->isUnconditional())
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user