diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-08 16:33:08 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-08 16:33:08 +0000 |
commit | 3a44a278cd790dbef005fdb5b727969519f34639 (patch) | |
tree | 3b276fc4543ee33b2bc43f554a23fcf7da9cf60f /gcc | |
parent | d0391daf761602b79315cca7045316515171dbbc (diff) | |
download | gcc-3a44a278cd790dbef005fdb5b727969519f34639.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145757 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/tree-dfa.c | 10 | ||||
-rw-r--r-- | gcc/tree-ssa-ccp.c | 22 |
3 files changed, 34 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7934933fb8f..cdb96fb7f65 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +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> * recog.c (ordered_comparison_operator): New. diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index d50b7ddb362..1738dd01266 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -600,13 +600,11 @@ add_referenced_var (tree var) { /* Scan DECL_INITIAL for pointer variables as they may contain address arithmetic referencing the address of other - variables. - Even non-constant initializers need to be walked, because - IPA passes might prove that their are invariant later on. */ + variables. As we are only interested in directly referenced + globals or referenced locals restrict this to initializers + than can refer to local variables. */ if (DECL_INITIAL (var) - /* Initializers of external variables are not useful to the - optimizers. */ - && !DECL_EXTERNAL (var)) + && DECL_CONTEXT (var) == current_function_decl) walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); return true; diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 2f396583b9a..a67850448a7 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -281,7 +281,15 @@ get_symbol_constant_value (tree sym) { STRIP_USELESS_TYPE_CONVERSION (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 have zero as the initializer if they may not be @@ -1243,6 +1251,12 @@ fold_const_aggregate_ref (tree t) if (tree_int_cst_equal (cfield, idx)) { 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; } break; @@ -1286,6 +1300,12 @@ fold_const_aggregate_ref (tree t) && ! DECL_BIT_FIELD (cfield)) { 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; } break; |