diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-06-06 02:08:52 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-06-06 02:08:52 +0000 |
commit | 3d6f60ec19e8c29d2b06eadb992c3b8380d60585 (patch) | |
tree | 99fcbccf09b9ca102d47b0b34f92f4358cadfd3f /lib/CodeGen/IfConversion.cpp | |
parent | 12112af5e8ed414ecc272bbd7ce835f87b36c98a (diff) |
If a unconditional branch is added to branch to the false path during ifcvt, the predicated block cannot be iteratively ifcvted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IfConversion.cpp')
-rw-r--r-- | lib/CodeGen/IfConversion.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index a81508f1c9..4572f4cbbc 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -165,8 +165,8 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) { RetVal = IfConvertSimple(BBI); DOUT << (RetVal ? "succeeded!" : "failed!") << "\n"; if (RetVal) - if (isRev) NumSimple++; - else NumSimpleRev++; + if (isRev) NumSimpleRev++; + else NumSimple++; break; } case ICTriangle: @@ -515,12 +515,25 @@ bool IfConverter::IfConvertSimple(BBInfo &BBI) { // to the 'false' branch. BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); MergeBlocks(BBI, *CvtBBI); - if (!isNextBlock(BBI.BB, NextBBI->BB)) + bool IterIfcvt = true; + if (!isNextBlock(BBI.BB, NextBBI->BB)) { + // 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. InsertUncondBranch(BBI.BB, NextBBI->BB, TII); + } std::copy(Cond.begin(), Cond.end(), std::back_inserter(BBI.Predicate)); // Update block info. BB can be iteratively if-converted. - BBI.Kind = ICReAnalyze; + if (IterIfcvt) + BBI.Kind = ICReAnalyze; ReTryPreds(BBI.BB); CvtBBI->Kind = ICDead; @@ -552,11 +565,24 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) { // predecessors. Otherwise, add a unconditional branch from 'true' to 'false'. 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)) + } else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB)) { InsertUncondBranch(TrueBBI.BB, FalseBBI.BB, TII); + // 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); @@ -565,7 +591,8 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) { std::back_inserter(BBI.Predicate)); // Update block info. BB can be iteratively if-converted. - BBI.Kind = ICReAnalyze; + if (IterIfcvt) + BBI.Kind = ICReAnalyze; ReTryPreds(BBI.BB); TrueBBI.Kind = ICDead; if (FalseBBDead) |