mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
ifcvt a triangle: don't merge ifcvt block with rejoin block if it can fall through to it. If merged, the resulting block is not a candidate for iterative ifcvting since it contains both predicated and non-predicated code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5cbf316686
commit
f476961ae6
@ -615,10 +615,18 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
|
|||||||
BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
|
BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
|
||||||
bool FalseBBDead = false;
|
bool FalseBBDead = false;
|
||||||
bool IterIfcvt = true;
|
bool IterIfcvt = true;
|
||||||
|
bool isFallThrough = isNextBlock(TrueBBI.BB, FalseBBI.BB);
|
||||||
|
if (!isFallThrough) {
|
||||||
|
// Only merge them if the true block does not fallthrough to the false
|
||||||
|
// block. By not merging them, we make it possible to iteratively
|
||||||
|
// ifcvt the blocks.
|
||||||
if (!HasEarlyExit && FalseBBI.BB->pred_size() == 2) {
|
if (!HasEarlyExit && FalseBBI.BB->pred_size() == 2) {
|
||||||
MergeBlocks(TrueBBI, FalseBBI);
|
MergeBlocks(TrueBBI, FalseBBI);
|
||||||
FalseBBDead = true;
|
FalseBBDead = true;
|
||||||
} else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB)) {
|
// Mixed predicated and unpredicated code. This cannot be iteratively
|
||||||
|
// predicated.
|
||||||
|
IterIfcvt = false;
|
||||||
|
} else {
|
||||||
InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
|
InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
|
||||||
TrueBBI.hasFallThrough = false;
|
TrueBBI.hasFallThrough = false;
|
||||||
if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
|
if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
|
||||||
@ -634,10 +642,14 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
|
|||||||
// if cmp executes.
|
// if cmp executes.
|
||||||
IterIfcvt = false;
|
IterIfcvt = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
MergeBlocks(BBI, TrueBBI);
|
MergeBlocks(BBI, TrueBBI);
|
||||||
|
// Remove entry to false edge.
|
||||||
|
if (BBI.BB->isSuccessor(FalseBBI.BB))
|
||||||
|
BBI.BB->removeSuccessor(FalseBBI.BB);
|
||||||
std::copy(BBI.BrCond.begin(), BBI.BrCond.end(),
|
std::copy(BBI.BrCond.begin(), BBI.BrCond.end(),
|
||||||
std::back_inserter(BBI.Predicate));
|
std::back_inserter(BBI.Predicate));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user