mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Ifcvt triangle: don't ifcvt 'true' BB if it has other predecessors; don't merge 'false' BB if it has other predecessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37382 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
df4da14948
commit
8c52938e44
@ -460,14 +460,29 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
|
|||||||
if (!TrueBBI.isPredicable)
|
if (!TrueBBI.isPredicable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// FIXME: Consider duplicating if BB is small.
|
||||||
|
if (BBI.TrueBB->pred_size() > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Predicate the 'true' block after removing its branch.
|
// Predicate the 'true' block after removing its branch.
|
||||||
TrueBBI.NonPredSize -= TII->RemoveBranch(*BBI.TrueBB);
|
TrueBBI.NonPredSize -= TII->RemoveBranch(*BBI.TrueBB);
|
||||||
PredicateBlock(TrueBBI, BBI.BrCond);
|
PredicateBlock(TrueBBI, BBI.BrCond);
|
||||||
|
|
||||||
// Join the 'true' and 'false' blocks by copying the instructions
|
// If 'true' block has a 'false' successor, add a early exit branch to it.
|
||||||
// from the 'false' block to the 'true' block.
|
if (TrueBBI.FalseBB) {
|
||||||
|
std::vector<MachineOperand> RevCond(TrueBBI.BrCond);
|
||||||
|
if (TII->ReverseBranchCondition(RevCond))
|
||||||
|
assert(false && "Unable to reverse branch condition!");
|
||||||
|
TII->InsertBranch(*BBI.TrueBB, TrueBBI.FalseBB, NULL, RevCond);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Join the 'true' and 'false' blocks if the 'false' block has no other
|
||||||
|
// predecessors. Otherwise, add a unconditional branch from 'true' to 'false'.
|
||||||
BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
|
BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
|
||||||
MergeBlocks(TrueBBI, FalseBBI);
|
if (FalseBBI.BB->pred_size() == 2)
|
||||||
|
MergeBlocks(TrueBBI, FalseBBI);
|
||||||
|
else
|
||||||
|
InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
|
||||||
|
|
||||||
// Now merge the entry of the triangle with the true block.
|
// Now merge the entry of the triangle with the true block.
|
||||||
BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB);
|
BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user