Commit 5f7ae6b6 by Jan Hubicka Committed by Jan Hubicka

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
parent 8b2b54f9
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> 2010-09-04 Richard Guenther <rguenther@suse.de>
PR bootstrap/45519 PR bootstrap/45519
......
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> 2010-09-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/45507 PR fortran/45507
......
/* { 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" } } */
...@@ -518,6 +518,7 @@ build_one_array (gimple swtch, int num, tree arr_index_type, gimple phi, ...@@ -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); array_type = build_array_type (value_type, arr_index_type);
ctor = build_constructor (array_type, info.constructors[num]); ctor = build_constructor (array_type, info.constructors[num]);
TREE_CONSTANT (ctor) = true; TREE_CONSTANT (ctor) = true;
TREE_STATIC (ctor) = true;
decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type); decl = build_decl (loc, VAR_DECL, NULL_TREE, array_type);
TREE_STATIC (decl) = 1; TREE_STATIC (decl) = 1;
......
...@@ -423,6 +423,7 @@ varpool_finalize_decl (tree decl) ...@@ -423,6 +423,7 @@ varpool_finalize_decl (tree decl)
there. */ there. */
else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)) else if (TREE_PUBLIC (decl) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl))
varpool_mark_needed_node (node); varpool_mark_needed_node (node);
node->const_value_known |= varpool_decide_const_value_known (node);
if (cgraph_global_info_ready) if (cgraph_global_info_ready)
varpool_assemble_pending_decls (); varpool_assemble_pending_decls ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment