aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.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-sccvn.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-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 3b42c24..b10d3e3 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1597,48 +1597,46 @@ simplify_unary_expression (tree rhs)
static tree
try_to_simplify (tree stmt, tree rhs)
{
+ tree tem;
+
/* For stores we can end up simplifying a SSA_NAME rhs. Just return
in this case, there is no point in doing extra work. */
if (TREE_CODE (rhs) == SSA_NAME)
return rhs;
- else
+
+ switch (TREE_CODE_CLASS (TREE_CODE (rhs)))
{
- switch (TREE_CODE_CLASS (TREE_CODE (rhs)))
- {
- /* For references, see if we find a result for the lookup,
- and use it if we do. */
- case tcc_declaration:
- /* Pull out any truly constant values. */
- if (TREE_READONLY (rhs)
- && TREE_STATIC (rhs)
- && DECL_INITIAL (rhs)
- && valid_gimple_expression_p (DECL_INITIAL (rhs)))
- return DECL_INITIAL (rhs);
-
- /* Fallthrough. */
- case tcc_reference:
- /* Do not do full-blown reference lookup here.
- ??? But like for tcc_declaration, we should simplify
- from constant initializers. */
-
- /* Fallthrough for some codes that can operate on registers. */
- if (!(TREE_CODE (rhs) == REALPART_EXPR
- || TREE_CODE (rhs) == IMAGPART_EXPR
- || TREE_CODE (rhs) == VIEW_CONVERT_EXPR))
- break;
- /* We could do a little more with unary ops, if they expand
- into binary ops, but it's debatable whether it is worth it. */
- case tcc_unary:
- return simplify_unary_expression (rhs);
- break;
- case tcc_comparison:
- case tcc_binary:
- return simplify_binary_expression (stmt, rhs);
- break;
- default:
- break;
- }
+ case tcc_declaration:
+ tem = get_symbol_constant_value (rhs);
+ if (tem)
+ return tem;
+ break;
+
+ case tcc_reference:
+ /* Do not do full-blown reference lookup here, but simplify
+ reads from constant aggregates. */
+ tem = fold_const_aggregate_ref (rhs);
+ if (tem)
+ return tem;
+
+ /* Fallthrough for some codes that can operate on registers. */
+ if (!(TREE_CODE (rhs) == REALPART_EXPR
+ || TREE_CODE (rhs) == IMAGPART_EXPR
+ || TREE_CODE (rhs) == VIEW_CONVERT_EXPR))
+ break;
+ /* We could do a little more with unary ops, if they expand
+ into binary ops, but it's debatable whether it is worth it. */
+ case tcc_unary:
+ return simplify_unary_expression (rhs);
+ break;
+ case tcc_comparison:
+ case tcc_binary:
+ return simplify_binary_expression (stmt, rhs);
+ break;
+ default:
+ break;
}
+
return rhs;
}