summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-05 10:54:14 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-10-05 10:54:14 +0000
commitce993cc21ae809ff5dc84558fa4c0ee7a4cc108d (patch)
tree8f305cd98368d269f8bb3b30639fd03210cf77df /gcc/tree-ssa-sccvn.c
parentb3988bd821b6c6b7e11039a5f71627bfd1b71972 (diff)
downloadgcc-ce993cc21ae809ff5dc84558fa4c0ee7a4cc108d.tar.gz
2011-10-05 Richard Guenther <rguenther@suse.de>
* gimple-fold.c (gimple_fold_stmt_to_constant_1): For ternary ops with an embedded expression valueize and fold that as well. * tree-ssa-sccvn.c (try_to_simplify): Also allow SSA name results from gimple_fold_stmt_to_constant_1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179543 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 003804b3ca8..208c272d371 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2967,27 +2967,29 @@ simplify_unary_expression (gimple stmt)
static tree
try_to_simplify (gimple stmt)
{
+ enum tree_code code = gimple_assign_rhs_code (stmt);
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 (gimple_assign_copy_p (stmt)
- && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
+ if (code == SSA_NAME)
return NULL_TREE;
/* First try constant folding based on our current lattice. */
- tem = gimple_fold_stmt_to_constant (stmt, vn_valueize);
- if (tem)
+ tem = gimple_fold_stmt_to_constant_1 (stmt, vn_valueize);
+ if (tem
+ && (TREE_CODE (tem) == SSA_NAME
+ || is_gimple_min_invariant (tem)))
return tem;
/* If that didn't work try combining multiple statements. */
- switch (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)))
+ switch (TREE_CODE_CLASS (code))
{
case tcc_reference:
- /* Fallthrough for some codes that can operate on registers. */
- if (!(TREE_CODE (gimple_assign_rhs1 (stmt)) == REALPART_EXPR
- || TREE_CODE (gimple_assign_rhs1 (stmt)) == IMAGPART_EXPR
- || TREE_CODE (gimple_assign_rhs1 (stmt)) == VIEW_CONVERT_EXPR))
+ /* Fallthrough for some unary codes that can operate on registers. */
+ if (!(code == REALPART_EXPR
+ || code == IMAGPART_EXPR
+ || code == 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. */