diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-27 23:02:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-27 23:02:32 +0000 |
commit | c2c90011a688c04a4e980282f08c267e081c4b00 (patch) | |
tree | f543ec6056c1b38c7b6bc1ae2fb4b4b1090734e1 /lib/CodeGen/CGExprScalar.cpp | |
parent | a02411e4d58b1730bea2a990822858ecc31e8eb1 (diff) |
Change the interface to ConstantFoldsToSimpleInteger to not encode
a bool + success into one tri-state integer, simplifying things.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 3e1debd820..6e558e7a6b 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -2257,8 +2257,9 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { // If we have 0 && RHS, see if we can elide RHS, if so, just return 0. // If we have 1 && X, just emit X without inserting the control flow. - if (int Cond = CGF.ConstantFoldsToSimpleInteger(E->getLHS())) { - if (Cond == 1) { // If we have 1 && X, just emit X. + bool LHSCondVal; + if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { + if (LHSCondVal) { // If we have 1 && X, just emit X. Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); // ZExt result to int or bool. return Builder.CreateZExtOrBitCast(RHSCond, ResTy, "land.ext"); @@ -2309,8 +2310,9 @@ Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) { // If we have 1 || RHS, see if we can elide RHS, if so, just return 1. // If we have 0 || X, just emit X without inserting the control flow. - if (int Cond = CGF.ConstantFoldsToSimpleInteger(E->getLHS())) { - if (Cond == -1) { // If we have 0 || X, just emit X. + bool LHSCondVal; + if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { + if (!LHSCondVal) { // If we have 0 || X, just emit X. Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); // ZExt result to int or bool. return Builder.CreateZExtOrBitCast(RHSCond, ResTy, "lor.ext"); @@ -2409,9 +2411,10 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) { // If the condition constant folds and can be elided, try to avoid emitting // the condition and the dead arm. - if (int Cond = CGF.ConstantFoldsToSimpleInteger(condExpr)){ + bool CondExprBool; + if (CGF.ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) { Expr *live = lhsExpr, *dead = rhsExpr; - if (Cond == -1) std::swap(live, dead); + if (!CondExprBool) std::swap(live, dead); // If the dead side doesn't have labels we need, and if the Live side isn't // the gnu missing ?: extension (which we could handle, but don't bother |