From: hubicka Date: Sat, 4 Sep 2010 16:02:38 +0000 (+0000) Subject: * gcc.dg/tree-ssa/foldconst-1.c: New testcase. X-Git-Tag: upstream/4.9.2~26895 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e579afdd943e828b6c17afe76c465bf4c72f0d93;p=platform%2Fupstream%2Flinaro-gcc.git * gcc.dg/tree-ssa/foldconst-1.c: New testcase. * tree-switch-conversion.c (build_one_array): Set constructor to be static. * varpool.c (varpool_finalize_decl): Compute const_value_known. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163860 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0ac706..feece9e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-09-04 Jan Hubicka + + * tree-switch-conversion.c (build_one_array): Set constructor to be + static. + * varpool.c (varpool_finalize_decl): Compute const_value_known. + 2010-09-04 Richard Guenther PR bootstrap/45519 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 52dd4e8..9e3da03 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-04 Jan Hubicka + + * gcc.dg/tree-ssa/foldconst-1.c: New testcase. + 2010-09-04 Janus Weil PR fortran/45507 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c b/gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c new file mode 100644 index 0000000..10414a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/foldconst-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +void bar (unsigned int); + +void +foo (void) +{ + char buf[1] = { 3 }; + const char *p = buf; + const char **q = &p; + unsigned int ch; + switch (**q) + { + case 1: ch = 5; break; + case 2: ch = 4; break; + case 3: ch = 3; break; + case 4: ch = 2; break; + case 5: ch = 1; break; + default: ch = 0; break; + } + bar (ch); +} +/* The switch should be switch converted and later constant propagated. */ +/* { dg-final { scan-tree-dump-not "CSWTCH" "optimized"} } */ +/* { dg-final { scan-tree-dump-not "switch" "optimized"} } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 7072af8..05c0a65 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -518,6 +518,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi, array_type = build_array_type (value_type, arr_index_type); ctor = build_constructor (array_type, info.constructors[num]); TREE_CONSTANT (ctor) = true; + TREE_STATIC (ctor) = true; decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type); TREE_STATIC (decl) = 1; diff --git a/gcc/varpool.c b/gcc/varpool.c index eac488f..2b08094 100644 --- a/gcc/varpool.c +++ b/gcc/varpool.c @@ -423,6 +423,7 @@ varpool_finalize_decl (tree decl) there. */ else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)) varpool_mark_needed_node (node); + node->const_value_known |= varpool_decide_const_value_known (node); if (cgraph_global_info_ready) varpool_assemble_pending_decls (); }