diff options
author | Chris Lattner <sabre@nondot.org> | 2011-04-16 23:15:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-04-16 23:15:35 +0000 |
commit | 56784f9de61fa607c03a56c3f774641a1189786d (patch) | |
tree | 7c0e7a0522b6b24707a9a50dc7fbe9f087a113ee /clang/test/CodeGen/conditional.c | |
parent | d6d4f987b487109878cf961d933caee925bc3036 (diff) | |
download | bcm5719-llvm-56784f9de61fa607c03a56c3f774641a1189786d.tar.gz bcm5719-llvm-56784f9de61fa607c03a56c3f774641a1189786d.zip |
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.
llvm-svn: 129649
Diffstat (limited to 'clang/test/CodeGen/conditional.c')
-rw-r--r-- | clang/test/CodeGen/conditional.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/test/CodeGen/conditional.c b/clang/test/CodeGen/conditional.c index d079aafd787..15e15f11e35 100644 --- a/clang/test/CodeGen/conditional.c +++ b/clang/test/CodeGen/conditional.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o %t +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s float test1(int cond, float a, float b) { return cond ? a : b; @@ -47,3 +47,22 @@ void test9(struct test9 *p) { p ? p : test9spare(); } +// CHECK: @test10 +// CHECK: select i1 {{.*}}, i32 4, i32 5 +int test10(int c) { + return c ? 4 : 5; +} +enum { Gronk = 5 }; + +// rdar://9289603 +// CHECK: @test11 +// CHECK: select i1 {{.*}}, i32 4, i32 5 +int test11(int c) { + return c ? 4 : Gronk; +} + +// CHECK: @test12 +// CHECK: select i1 {{.*}}, double 4.0{{.*}}, double 2.0 +double test12(int c) { + return c ? 4.0 : 2.0; +} |