aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/IfConversion.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-06-07 08:13:00 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-06-07 08:13:00 +0000
commitf476961ae6839496b715339cc9c2e28d5c1afbf5 (patch)
tree3f4d3b1b8999293ba3698dbcfbc3e31e07637d75 /lib/CodeGen/IfConversion.cpp
parent5cbf31668639efa02b8b5261dba9942143729693 (diff)
downloadexternal_llvm-f476961ae6839496b715339cc9c2e28d5c1afbf5.zip
external_llvm-f476961ae6839496b715339cc9c2e28d5c1afbf5.tar.gz
external_llvm-f476961ae6839496b715339cc9c2e28d5c1afbf5.tar.bz2
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
Diffstat (limited to 'lib/CodeGen/IfConversion.cpp')
-rw-r--r--lib/CodeGen/IfConversion.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index 5b133a6..64f2faf 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -615,29 +615,41 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
bool FalseBBDead = false;
bool IterIfcvt = true;
- if (!HasEarlyExit && FalseBBI.BB->pred_size() == 2) {
- MergeBlocks(TrueBBI, FalseBBI);
- FalseBBDead = true;
- } else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB)) {
- InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
- TrueBBI.hasFallThrough = false;
- if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
- // Now ifcvt'd block will look like this:
- // BB:
- // ...
- // t, f = cmp
- // if t op
- // b BBf
- //
- // We cannot further ifcvt this block because the unconditional branch will
- // have to be predicated on the new condition, that will not be available
- // if cmp executes.
+ 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) {
+ MergeBlocks(TrueBBI, FalseBBI);
+ FalseBBDead = true;
+ // Mixed predicated and unpredicated code. This cannot be iteratively
+ // predicated.
IterIfcvt = false;
+ } else {
+ InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII);
+ TrueBBI.hasFallThrough = false;
+ if (BBI.ModifyPredicate || TrueBBI.ModifyPredicate)
+ // Now ifcvt'd block will look like this:
+ // BB:
+ // ...
+ // t, f = cmp
+ // if t op
+ // b BBf
+ //
+ // We cannot further ifcvt this block because the unconditional branch will
+ // have to be predicated on the new condition, that will not be available
+ // if cmp executes.
+ IterIfcvt = false;
+ }
}
// Now merge the entry of the triangle with the true block.
BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB);
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::back_inserter(BBI.Predicate));