aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-16 23:15:35 +0000
committerChris Lattner <sabre@nondot.org>2011-04-16 23:15:35 +0000
commitc6bea67efc38b075c401ebdb6ae97afa08cbb51d (patch)
tree3bd202d5bec2af1b8341fff28d39254bbedb3a56 /lib/CodeGen
parent32ac00d05b3e12bb155f95dfcede7e66ab26c234 (diff)
fix rdar://9289603 - clang should fold trivial ?: for enums as well as integer constants into select at -O0
by making the isCheapEnoughToEvaluateUnconditionally predicate handle anything that folds to a constant. In particular, we now fold enums. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129649 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 556dbf54ec..d4463c17a3 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -2401,9 +2401,8 @@ static bool isCheapEnoughToEvaluateUnconditionally(const Expr *E,
CodeGenFunction &CGF) {
E = E->IgnoreParens();
- // TODO: Allow anything we can constant fold to an integer or fp constant.
- if (isa<IntegerLiteral>(E) || isa<CharacterLiteral>(E) ||
- isa<FloatingLiteral>(E))
+ // Anything that is an integer or floating point constant is fine.
+ if (E->isConstantInitializer(CGF.getContext(), false))
return true;
// Non-volatile automatic variables too, to get "cond ? X : Y" where