aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/IfConversion.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-06-01 20:29:21 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-06-01 20:29:21 +0000
commitb5a06907881751a2f16e8b5bc049684ba1532dee (patch)
treee7efde4f3e4cbd63d5333d9832fdbb57193287a0 /lib/CodeGen/IfConversion.cpp
parent8e21fb7df8530c239f7bd590ff940253ac928aa3 (diff)
downloadexternal_llvm-b5a06907881751a2f16e8b5bc049684ba1532dee.zip
external_llvm-b5a06907881751a2f16e8b5bc049684ba1532dee.tar.gz
external_llvm-b5a06907881751a2f16e8b5bc049684ba1532dee.tar.bz2
Correctly mark early-exit on the false path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37387 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IfConversion.cpp')
-rw-r--r--lib/CodeGen/IfConversion.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index 77604dd..9efceb0 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -33,6 +33,7 @@ namespace {
ICReAnalyze, // BB must be re-analyzed.
ICNotClassfied, // BB data valid, but not classified.
ICEarlyExit, // BB is entry of an early-exit sub-CFG.
+ ICEarlyExitFalse,// Same as ICEarlyExit, but on the false path.
ICTriangle, // BB is entry of a triangle sub-CFG.
ICDiamond, // BB is entry of a diamond sub-CFG.
ICChild, // BB is part of the sub-CFG that'll be predicated.
@@ -151,6 +152,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
// One or more of 'childrean' have been modified, abort!
break;
case ICEarlyExit:
+ case ICEarlyExitFalse:
DOUT << "Ifcvt (Early exit): BB#" << BBI.BB->getNumber() << "\n";
Change |= IfConvertEarlyExit(BBI);
break;
@@ -239,7 +241,7 @@ void IfConverter::StructuralAnalysis(MachineBasicBlock *BB) {
TrueBBI.Kind = ICChild;
} else if (!(TrueBBI.hasEarlyExit && TrueNumPreds <= 1) &&
(FalseBBI.hasEarlyExit && FalseNumPreds <=1)) {
- BBI.Kind = ICEarlyExit;
+ BBI.Kind = ICEarlyExitFalse;
FalseBBI.Kind = ICChild;
} else if (TrueBBI.TrueBB && TrueBBI.TrueBB == BBI.FalseBB) {
// Triangle:
@@ -335,6 +337,7 @@ bool IfConverter::AnalyzeBlocks(MachineFunction &MF,
BBInfo &BBI = BBAnalysis[BB->getNumber()];
switch (BBI.Kind) {
case ICEarlyExit:
+ case ICEarlyExitFalse:
case ICTriangle:
case ICDiamond:
Candidates.push_back(&BBI);
@@ -406,6 +409,8 @@ static void InsertUncondBranch(MachineBasicBlock *BB, MachineBasicBlock *ToBB,
/// IfConvertEarlyExit - If convert a early exit sub-CFG.
///
bool IfConverter::IfConvertEarlyExit(BBInfo &BBI) {
+ bool ReverseCond = BBI.Kind == ICEarlyExitFalse;
+
BBI.Kind = ICNotClassfied;
BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()];
@@ -413,15 +418,11 @@ bool IfConverter::IfConvertEarlyExit(BBInfo &BBI) {
BBInfo *CvtBBI = &TrueBBI;
BBInfo *NextBBI = &FalseBBI;
- bool ReserveCond = false;
- if (TrueBBI.Kind != ICChild) {
- std::swap(CvtBBI, NextBBI);
- ReserveCond = true;
- }
-
std::vector<MachineOperand> NewCond(BBI.BrCond);
- if (ReserveCond)
+ if (ReverseCond) {
+ std::swap(CvtBBI, NextBBI);
TII->ReverseBranchCondition(NewCond);
+ }
FeasibilityAnalysis(*CvtBBI, NewCond);
if (!CvtBBI->isPredicable)
return false;