[cfe-commits] r59114 - /cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Chris Lattner
sabre at nondot.org
Wed Nov 12 00:08:14 PST 2008
Author: lattner
Date: Wed Nov 12 02:08:13 2008
New Revision: 59114
URL: http://llvm.org/viewvc/llvm-project?rev=59114&view=rev
Log:
Use EmitBranchOnBoolExpr in VisitConditionalOperator. This
shrinks code yet again by a bit.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=59114&r1=59113&r2=59114&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Nov 12 02:08:13 2008
@@ -1129,14 +1129,23 @@
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.?");
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.:");
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.cont");
+ Value *CondVal = 0;
- // Evaluate the conditional, then convert it to bool. We do this explicitly
- // because we need the unconverted value if this is a GNU ?: expression with
- // missing middle value.
- Value *CondVal = CGF.EmitScalarExpr(E->getCond());
- Value *CondBoolVal =CGF.EmitScalarConversion(CondVal, E->getCond()->getType(),
- CGF.getContext().BoolTy);
- Builder.CreateCondBr(CondBoolVal, LHSBlock, RHSBlock);
+ // If we have the GNU missing condition extension, evaluate the conditional
+ // and then convert it to bool the hard way. We do this explicitly
+ // because we need the unconverted value for the missing middle value of
+ // the ?:.
+ if (E->getLHS() == 0) {
+ CondVal = CGF.EmitScalarExpr(E->getCond());
+ Value *CondBoolVal =
+ CGF.EmitScalarConversion(CondVal, E->getCond()->getType(),
+ CGF.getContext().BoolTy);
+ Builder.CreateCondBr(CondBoolVal, LHSBlock, RHSBlock);
+ } else {
+ // Otherwise, just use EmitBranchOnBoolExpr to get small and simple code for
+ // the branch on bool.
+ CGF.EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock);
+ }
CGF.EmitBlock(LHSBlock);
More information about the cfe-commits
mailing list