From 8ed680cce3d0cff361f352abce75a917093f0656 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 5 Jun 2007 01:31:40 +0000 Subject: [PATCH] If the predicated block requires an early exit, end the block there and add a unconditional branch to false block. AnalyzeBranch() does not understand early exits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37430 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/IfConversion.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index bd50121f4b3..1023f8fd950 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -527,7 +527,8 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) { PredicateBlock(TrueBBI, BBI.BrCond); // If 'true' block has a 'false' successor, add an exit branch to it. - if (TrueBBI.FalseBB) { + bool HasEarlyExit = TrueBBI.FalseBB != NULL; + if (HasEarlyExit) { std::vector RevCond(TrueBBI.BrCond); if (TII->ReverseBranchCondition(RevCond)) assert(false && "Unable to reverse branch condition!"); @@ -538,7 +539,7 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) { // predecessors. Otherwise, add a unconditional branch from 'true' to 'false'. BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; bool FalseBBDead = false; - if (FalseBBI.BB->pred_size() == 2) { + if (!HasEarlyExit && FalseBBI.BB->pred_size() == 2) { MergeBlocks(TrueBBI, FalseBBI); FalseBBDead = true; } else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB)) -- 2.34.1