Commit 697c3575 by Jan Hubicka Committed by Jan Hubicka

tree-ssa-ccp.c (fold_ctor_reference): New function.

	* tree-ssa-ccp.c (fold_ctor_reference): New function.
	(fold_const_aggregate_ref): Use it.
	* fold-const.c (canonicalize_constructor_val): Check that we don't fold
	into external static.

From-SVN: r164688
parent 2770264a
2010-09-28 Jan Hubicka <jh@suse.cz>
* tree-ssa-ccp.c (fold_ctor_reference): New function.
(fold_const_aggregate_ref): Use it.
* fold-const.c (canonicalize_constructor_val): Check that we don't fold
into external static.
2010-09-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2010-09-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/44452 PR target/44452
...@@ -54,12 +54,11 @@ static_object_in_other_unit_p (tree decl) ...@@ -54,12 +54,11 @@ static_object_in_other_unit_p (tree decl)
struct varpool_node *vnode; struct varpool_node *vnode;
struct cgraph_node *node; struct cgraph_node *node;
if (!TREE_STATIC (decl) if (!TREE_STATIC (decl) || DECL_COMDAT (decl))
|| TREE_PUBLIC (decl) || DECL_COMDAT (decl))
return false; return false;
/* External flag is set, so we deal with C++ reference /* External flag is set, so we deal with C++ reference
to static object from other file. */ to static object from other file. */
if (DECL_EXTERNAL (decl)) if (DECL_EXTERNAL (decl) && TREE_CODE (decl) == VAR_DECL)
{ {
/* Just be sure it is not big in frontend setting /* Just be sure it is not big in frontend setting
flags incorrectly. Those variables should never flags incorrectly. Those variables should never
...@@ -68,6 +67,8 @@ static_object_in_other_unit_p (tree decl) ...@@ -68,6 +67,8 @@ static_object_in_other_unit_p (tree decl)
|| !vnode->finalized); || !vnode->finalized);
return true; return true;
} }
if (TREE_PUBLIC (decl))
return false;
/* We are not at ltrans stage; so don't worry about WHOPR. */ /* We are not at ltrans stage; so don't worry about WHOPR. */
if (!flag_ltrans) if (!flag_ltrans)
return false; return false;
......
2010-09-28 Jan Hubicka <jh@suse.cz>
* gcc.dg/tree-ssa/foldconst-5.c: New testcase.
2010-09-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2010-09-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/44452 PR target/44452
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-ccp1" } */
static const char a[5]="t";
static const int b[5]={1,2};
static const struct a {int a : 6; int b : 6;} c = {5,9};
test()
{
return a[2]+b[1]+b[3]+c.b;
}
/* { dg-final { scan-tree-dump "return 11;" "ccp1" } } */
/* { dg-final { cleanup-tree-dump "ccp1" } } */
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