From d95377341b7bf916ec102cebf302a90dc1ce37b8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 12 Nov 2008 08:13:36 +0000 Subject: [PATCH] Handle Unary ! in EmitBranchOnBoolExpr, so that we can efficiently codegen stuff like "if (!(X && Y))" llvm-svn: 59115 --- clang/lib/CodeGen/CodeGenFunction.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index a797d75963f5..0756de7a8a7b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -263,7 +263,12 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock); return; } - + } + + if (const UnaryOperator *CondUOp = dyn_cast(Cond)) { + // br(!x, t, f) -> br(x, f, t) + if (CondUOp->getOpcode() == UnaryOperator::LNot) + return EmitBranchOnBoolExpr(CondUOp->getSubExpr(), FalseBlock, TrueBlock); } // Emit the code with the fully general case.