foldconst-1.c: New testcase.

* 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.

From-SVN: r163860
This commit is contained in:
Jan Hubicka 2010-09-04 18:02:38 +02:00 committed by Jan Hubicka
parent 8b2b54f9d6
commit 5f7ae6b656
5 changed files with 38 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2010-09-04 Jan Hubicka <jh@suse.cz>
* 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 <rguenther@suse.de>
PR bootstrap/45519

View File

@ -1,3 +1,7 @@
2010-09-04 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/foldconst-1.c: New testcase.
2010-09-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/45507

View File

@ -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" } } */

View File

@ -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;

View File

@ -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 ();
}