summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.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/gimple-fold.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/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 179535ef566..fcfbcc8f5b3 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -2569,6 +2569,19 @@ gimple_fold_stmt_to_constant_1 (gimple stmt, tree (*valueize) (tree))
tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
tree op2 = (*valueize) (gimple_assign_rhs3 (stmt));
+ /* Fold embedded expressions in ternary codes. */
+ if ((subcode == COND_EXPR
+ || subcode == VEC_COND_EXPR)
+ && COMPARISON_CLASS_P (op0))
+ {
+ tree op00 = (*valueize) (TREE_OPERAND (op0, 0));
+ tree op01 = (*valueize) (TREE_OPERAND (op0, 1));
+ tree tem = fold_binary_loc (loc, TREE_CODE (op0),
+ TREE_TYPE (op0), op00, op01);
+ if (tem)
+ op0 = tem;
+ }
+
return fold_ternary_loc (loc, subcode,
gimple_expr_type (stmt), op0, op1, op2);
}