aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-12 07:46:33 +0000
committerChris Lattner <sabre@nondot.org>2008-11-12 07:46:33 +0000
commit9bc47e29dce8f095be7a6d07dbb02a5a7a112949 (patch)
treed2cb6a21700ee6cb983a889e5b6704676f5f2f40 /lib/CodeGen/CodeGenFunction.h
parent32fea9d18cc3658a1b01df5ca6f2ac302625c61d (diff)
Make emission of 'if' conditions much more sophisticated when we
have a condition that is an &&/||. Before we used to compile things like this: int test() { if (x && y) foo(); else bar(); } into: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_rhs, label %land_cont land_rhs: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br label %land_cont land_cont: ; preds = %land_rhs, %entry %4 = phi i1 [ false, %entry ], [ %3, %land_rhs ] ; <i1> [#uses=1] br i1 %4, label %ifthen, label %ifelse ifthen: ; preds = %land_cont %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_cont %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Now we turn it into the much more svelte code: %0 = load i32* @x ; <i32> [#uses=1] %1 = icmp ne i32 %0, 0 ; <i1> [#uses=1] br i1 %1, label %land_lhs_true, label %ifelse land_lhs_true: ; preds = %entry %2 = load i32* @y ; <i32> [#uses=1] %3 = icmp ne i32 %2, 0 ; <i1> [#uses=1] br i1 %3, label %ifthen, label %ifelse ifthen: ; preds = %land_lhs_true %call = call i32 (...)* @foo() ; <i32> [#uses=0] br label %ifend ifelse: ; preds = %land_lhs_true, %entry %call1 = call i32 (...)* @bar() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifelse, %ifthen Note the lack of a phi node. This shrinks the -O0 .ll file for 176.gcc/expr.c from 43176 to 40267 lines. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59111 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r--lib/CodeGen/CodeGenFunction.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 38d9cf31d0..574e957eb9 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -564,6 +564,8 @@ public:
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
private:
+ void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
+ llvm::BasicBlock *FalseBlock);
/// EmitIndirectSwitches - Emit code for all of the switch
/// instructions in IndirectSwitches.