diff options
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CodeGen/2008-12-02-logical-or-fold.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 8c4303b467c..7f417b374aa 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1077,9 +1077,9 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { return Builder.CreateZExt(RHSCond, CGF.LLVMIntTy, "lor.ext"); } - // 1 || RHS: If it is safe, just elide the RHS, and return 0. + // 1 || RHS: If it is safe, just elide the RHS, and return 1. if (!CGF.ContainsLabel(E->getRHS())) - return llvm::Constant::getNullValue(CGF.LLVMIntTy); + return llvm::ConstantInt::get(CGF.LLVMIntTy, 1); } llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); diff --git a/clang/test/CodeGen/2008-12-02-logical-or-fold.c b/clang/test/CodeGen/2008-12-02-logical-or-fold.c new file mode 100644 index 00000000000..ba8f86c4fc5 --- /dev/null +++ b/clang/test/CodeGen/2008-12-02-logical-or-fold.c @@ -0,0 +1,4 @@ +// RUN: clang -emit-llvm -o - %s | grep "store i32 1" +// PR3150 + +int a() {return 1||1;} |

