diff options
-rw-r--r-- | clang/lib/CodeGen/CGStmt.cpp | 6 | ||||
-rw-r--r-- | clang/test/CodeGen/branch-on-bool.c | 8 |
2 files changed, 4 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index 1d91e926865..8325dddbb8a 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -657,7 +657,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) { // C99 6.8.5p2/p4: The first substatement is executed if the expression // compares unequal to 0. The condition must be a scalar type. - EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock); + llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond()); + Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock); if (ExitBlock != LoopExit.getBlock()) { EmitBlock(ExitBlock); @@ -737,7 +738,8 @@ void CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S) { // The body is executed if the expression, contextually converted // to bool, is true. - EmitBranchOnBoolExpr(S.getCond(), ForBody, ExitBlock); + llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond()); + Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock); if (ExitBlock != LoopExit.getBlock()) { EmitBlock(ExitBlock); diff --git a/clang/test/CodeGen/branch-on-bool.c b/clang/test/CodeGen/branch-on-bool.c index 78dae1b1fd7..98a3845fba2 100644 --- a/clang/test/CodeGen/branch-on-bool.c +++ b/clang/test/CodeGen/branch-on-bool.c @@ -12,11 +12,3 @@ void fold_if(int a, int b) { else bar(); } - -void fold_for(int a, int b) { - // CHECK: define {{.*}} @fold_for( - // CHECK-NOT: = phi - // CHECK: } - for (int i = 0; a && i < b; ++i) foo(); - for (int i = 0; a || i < b; ++i) bar(); -} |