aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-03-15 14:34:18 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-03-15 14:34:18 +0000
commited97ddc649f7edc10e75e05c92cf49fdfbdd6150 (patch)
tree8d621c599271cc9675f83006117dc15c1f907030 /gcc/tree-ssa-ccp.c
parentab55105446b5bd197d6e41a7056036b27eda1154 (diff)
downloadgcc-ed97ddc649f7edc10e75e05c92cf49fdfbdd6150.zip
gcc-ed97ddc649f7edc10e75e05c92cf49fdfbdd6150.tar.gz
gcc-ed97ddc649f7edc10e75e05c92cf49fdfbdd6150.tar.bz2
tree-ssa-ccp.c (get_symbol_constant_value): Export.
2008-03-15 Richard Guenther <rguenther@suse.de> * tree-ssa-ccp.c (get_symbol_constant_value): Export. (fold_const_aggregate_ref): Likewise. (get_value): Return NULL if we don't have any values. (ccp_finalize): Set const_val to NULL after freeing it. * tree-flow.h (get_symbol_constant_value): Declare. (fold_const_aggregate_ref): Likewise. * tree-ssa-sccvn.c (try_to_simplify): Use them. * gcc.dg/pr23911.c: Adjust testcase. * gcc.dg/tree-ssa/pr14841.c: Likewise. * gcc.dg/tree-ssa/20030922-2.c: Likewise. From-SVN: r133251
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 8b8a902..a1eaab2 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -295,23 +295,22 @@ ccp_decl_initial_min_invariant (tree t)
/* If SYM is a constant variable with known value, return the value.
NULL_TREE is returned otherwise. */
-static tree
+tree
get_symbol_constant_value (tree sym)
{
if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
- && !MTAG_P (sym)
- /* Check if a read-only definition may be overridden at
- link and run time. */
- && targetm.binds_local_p (sym))
+ && !MTAG_P (sym))
{
tree val = DECL_INITIAL (sym);
if (val
&& ccp_decl_initial_min_invariant (val))
return val;
/* Variables declared 'const' without an initializer
- have zero as the intializer. */
+ have zero as the intializer if they may not be
+ overridden at link or run time. */
if (!val
+ && targetm.binds_local_p (sym)
&& (INTEGRAL_TYPE_P (TREE_TYPE (sym))
|| SCALAR_FLOAT_TYPE_P (TREE_TYPE (sym))))
return fold_convert (TREE_TYPE (sym), integer_zero_node);
@@ -406,8 +405,12 @@ get_default_value (tree var)
static inline prop_value_t *
get_value (tree var)
{
- prop_value_t *val = &const_val[SSA_NAME_VERSION (var)];
+ prop_value_t *val;
+ if (const_val == NULL)
+ return NULL;
+
+ val = &const_val[SSA_NAME_VERSION (var)];
if (val->lattice_val == UNINITIALIZED)
*val = get_default_value (var);
@@ -722,6 +725,7 @@ ccp_finalize (void)
bool something_changed = substitute_and_fold (const_val, false);
free (const_val);
+ const_val = NULL;
return something_changed;;
}
@@ -1026,7 +1030,7 @@ ccp_fold (tree stmt)
ARRAY_REF or COMPONENT_REF into constant aggregates. Return
NULL_TREE otherwise. */
-static tree
+tree
fold_const_aggregate_ref (tree t)
{
prop_value_t *value;