Commit 75ccc1e7 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/36291 (GCC is slow and memory-hungry building sipQtGuipart.cpp)

2009-04-08  Richard Guenther  <rguenther@suse.de>

	PR middle-end/36291
	* tree-dfa.c (add_referenced_var): Do not recurse into
	global initializers.
	* tree-ssa-ccp.c (get_symbol_constant_value): Add newly
	exposed variables.
	(fold_const_aggregate_ref): Likewise.

From-SVN: r145757
parent f6f5e3a1
2009-04-08 Richard Guenther <rguenther@suse.de>
PR middle-end/36291
* tree-dfa.c (add_referenced_var): Do not recurse into
global initializers.
* tree-ssa-ccp.c (get_symbol_constant_value): Add newly
exposed variables.
(fold_const_aggregate_ref): Likewise.
2009-04-08 Paolo Bonzini <bonzini@gnu.org> 2009-04-08 Paolo Bonzini <bonzini@gnu.org>
* recog.c (ordered_comparison_operator): New. * recog.c (ordered_comparison_operator): New.
......
...@@ -600,13 +600,11 @@ add_referenced_var (tree var) ...@@ -600,13 +600,11 @@ add_referenced_var (tree var)
{ {
/* Scan DECL_INITIAL for pointer variables as they may contain /* Scan DECL_INITIAL for pointer variables as they may contain
address arithmetic referencing the address of other address arithmetic referencing the address of other
variables. variables. As we are only interested in directly referenced
Even non-constant initializers need to be walked, because globals or referenced locals restrict this to initializers
IPA passes might prove that their are invariant later on. */ than can refer to local variables. */
if (DECL_INITIAL (var) if (DECL_INITIAL (var)
/* Initializers of external variables are not useful to the && DECL_CONTEXT (var) == current_function_decl)
optimizers. */
&& !DECL_EXTERNAL (var))
walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0);
return true; return true;
......
...@@ -281,7 +281,15 @@ get_symbol_constant_value (tree sym) ...@@ -281,7 +281,15 @@ get_symbol_constant_value (tree sym)
{ {
STRIP_USELESS_TYPE_CONVERSION (val); STRIP_USELESS_TYPE_CONVERSION (val);
if (is_gimple_min_invariant (val)) if (is_gimple_min_invariant (val))
return val; {
if (TREE_CODE (val) == ADDR_EXPR)
{
tree base = get_base_address (TREE_OPERAND (val, 0));
if (base && TREE_CODE (base) == VAR_DECL)
add_referenced_var (base);
}
return val;
}
} }
/* Variables declared 'const' without an initializer /* Variables declared 'const' without an initializer
have zero as the initializer if they may not be have zero as the initializer if they may not be
...@@ -1243,6 +1251,12 @@ fold_const_aggregate_ref (tree t) ...@@ -1243,6 +1251,12 @@ fold_const_aggregate_ref (tree t)
if (tree_int_cst_equal (cfield, idx)) if (tree_int_cst_equal (cfield, idx))
{ {
STRIP_USELESS_TYPE_CONVERSION (cval); STRIP_USELESS_TYPE_CONVERSION (cval);
if (TREE_CODE (cval) == ADDR_EXPR)
{
tree base = get_base_address (TREE_OPERAND (cval, 0));
if (base && TREE_CODE (base) == VAR_DECL)
add_referenced_var (base);
}
return cval; return cval;
} }
break; break;
...@@ -1286,6 +1300,12 @@ fold_const_aggregate_ref (tree t) ...@@ -1286,6 +1300,12 @@ fold_const_aggregate_ref (tree t)
&& ! DECL_BIT_FIELD (cfield)) && ! DECL_BIT_FIELD (cfield))
{ {
STRIP_USELESS_TYPE_CONVERSION (cval); STRIP_USELESS_TYPE_CONVERSION (cval);
if (TREE_CODE (cval) == ADDR_EXPR)
{
tree base = get_base_address (TREE_OPERAND (cval, 0));
if (base && TREE_CODE (base) == VAR_DECL)
add_referenced_var (base);
}
return cval; return cval;
} }
break; break;
......
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