diff options
author | Richard Guenther <rguenther@suse.de> | 2009-08-07 17:02:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-08-07 17:02:43 +0000 |
commit | 0adef8e940a816abaee2224d8c0cf2acd73d9a63 (patch) | |
tree | c12c6c473ae4311d839b3b503f10c0d0d6515be6 /gcc/tree-ssa-ccp.c | |
parent | 7553122861e1a5d694adbefbbbbfe2a479f91171 (diff) | |
download | gcc-0adef8e940a816abaee2224d8c0cf2acd73d9a63.zip gcc-0adef8e940a816abaee2224d8c0cf2acd73d9a63.tar.gz gcc-0adef8e940a816abaee2224d8c0cf2acd73d9a63.tar.bz2 |
re PR tree-optimization/40999 (ICE in extract_component, at tree-complex.c:625)
2009-08-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40999
* tree-ssa-ccp.c (get_symbol_constant_value): Handle CONST_DECLs.
(maybe_fold_reference): Lookup constant initializers.
(fold_gimple_assign): Likewise.
* gfortran.dg/pr40999.f: New testcase.
From-SVN: r150572
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index c507f45..f39d272 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -276,7 +276,8 @@ tree get_symbol_constant_value (tree sym) { if (TREE_STATIC (sym) - && TREE_READONLY (sym)) + && (TREE_READONLY (sym) + || TREE_CODE (sym) == CONST_DECL)) { tree val = DECL_INITIAL (sym); if (val) @@ -288,7 +289,11 @@ get_symbol_constant_value (tree sym) { tree base = get_base_address (TREE_OPERAND (val, 0)); if (base && TREE_CODE (base) == VAR_DECL) - add_referenced_var (base); + { + TREE_ADDRESSABLE (base) = 1; + if (gimple_referenced_vars (cfun)) + add_referenced_var (base); + } } return val; } @@ -2337,6 +2342,19 @@ maybe_fold_reference (tree expr, bool is_lhs) return expr; } } + else if (!is_lhs + && DECL_P (*t)) + { + tree tem = get_symbol_constant_value (*t); + if (tem) + { + *t = tem; + tem = maybe_fold_reference (expr, is_lhs); + if (tem) + return tem; + return expr; + } + } return NULL_TREE; } @@ -2739,6 +2757,9 @@ fold_gimple_assign (gimple_stmt_iterator *si) CONSTRUCTOR_ELTS (rhs)); } + else if (DECL_P (rhs)) + return get_symbol_constant_value (rhs); + /* If we couldn't fold the RHS, hand over to the generic fold routines. */ if (result == NULL_TREE) |