Commit a5eaec42 by Richard Biener Committed by Richard Biener

tree-ssa-sccvn.c (vn_get_expr_for): Valueize operands before folding the expression.

2014-05-08  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (vn_get_expr_for): Valueize operands before
	folding the expression.
	(valueize_expr): Remove.
	(visit_reference_op_load): Do not valueize the result of
	vn_get_expr_for.
	(simplify_binary_expression): Likewise.
	(simplify_unary_expression): Likewise.

From-SVN: r210211
parent cceaf54a
2014-05-08 Richard Biener <rguenther@suse.de> 2014-05-08 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (vn_get_expr_for): Valueize operands before
folding the expression.
(valueize_expr): Remove.
(visit_reference_op_load): Do not valueize the result of
vn_get_expr_for.
(simplify_binary_expression): Likewise.
(simplify_unary_expression): Likewise.
2014-05-08 Richard Biener <rguenther@suse.de>
* gimplify.c (gimplify_call_expr): Use saved fnptrtype for * gimplify.c (gimplify_call_expr): Use saved fnptrtype for
looking at TYPE_ARG_TYPES. looking at TYPE_ARG_TYPES.
......
...@@ -414,8 +414,8 @@ vn_get_expr_for (tree name) ...@@ -414,8 +414,8 @@ vn_get_expr_for (tree name)
if (!is_gimple_assign (def_stmt)) if (!is_gimple_assign (def_stmt))
return vn->valnum; return vn->valnum;
/* FIXME tuples. This is incomplete and likely will miss some /* Note that we can valueize here because we clear the cached
simplifications. */ simplified expressions after each optimistic iteration. */
code = gimple_assign_rhs_code (def_stmt); code = gimple_assign_rhs_code (def_stmt);
switch (TREE_CODE_CLASS (code)) switch (TREE_CODE_CLASS (code))
{ {
...@@ -427,20 +427,21 @@ vn_get_expr_for (tree name) ...@@ -427,20 +427,21 @@ vn_get_expr_for (tree name)
0)) == SSA_NAME) 0)) == SSA_NAME)
expr = fold_build1 (code, expr = fold_build1 (code,
gimple_expr_type (def_stmt), gimple_expr_type (def_stmt),
TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0)); vn_valueize (TREE_OPERAND
(gimple_assign_rhs1 (def_stmt), 0)));
break; break;
case tcc_unary: case tcc_unary:
expr = fold_build1 (code, expr = fold_build1 (code,
gimple_expr_type (def_stmt), gimple_expr_type (def_stmt),
gimple_assign_rhs1 (def_stmt)); vn_valueize (gimple_assign_rhs1 (def_stmt)));
break; break;
case tcc_binary: case tcc_binary:
expr = fold_build2 (code, expr = fold_build2 (code,
gimple_expr_type (def_stmt), gimple_expr_type (def_stmt),
gimple_assign_rhs1 (def_stmt), vn_valueize (gimple_assign_rhs1 (def_stmt)),
gimple_assign_rhs2 (def_stmt)); vn_valueize (gimple_assign_rhs2 (def_stmt)));
break; break;
case tcc_exceptional: case tcc_exceptional:
...@@ -2759,7 +2760,6 @@ defs_to_varying (gimple stmt) ...@@ -2759,7 +2760,6 @@ defs_to_varying (gimple stmt)
} }
static bool expr_has_constants (tree expr); static bool expr_has_constants (tree expr);
static tree valueize_expr (tree expr);
/* Visit a copy between LHS and RHS, return true if the value number /* Visit a copy between LHS and RHS, return true if the value number
changed. */ changed. */
...@@ -2900,7 +2900,7 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt) ...@@ -2900,7 +2900,7 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
|| TREE_CODE (val) == VIEW_CONVERT_EXPR) || TREE_CODE (val) == VIEW_CONVERT_EXPR)
&& TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME) && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME)
{ {
tree tem = valueize_expr (vn_get_expr_for (TREE_OPERAND (val, 0))); tree tem = vn_get_expr_for (TREE_OPERAND (val, 0));
if ((CONVERT_EXPR_P (tem) if ((CONVERT_EXPR_P (tem)
|| TREE_CODE (tem) == VIEW_CONVERT_EXPR) || TREE_CODE (tem) == VIEW_CONVERT_EXPR)
&& (tem = fold_unary_ignore_overflow (TREE_CODE (val), && (tem = fold_unary_ignore_overflow (TREE_CODE (val),
...@@ -3210,26 +3210,6 @@ stmt_has_constants (gimple stmt) ...@@ -3210,26 +3210,6 @@ stmt_has_constants (gimple stmt)
return false; return false;
} }
/* Replace SSA_NAMES in expr with their value numbers, and return the
result.
This is performed in place. */
static tree
valueize_expr (tree expr)
{
switch (TREE_CODE_CLASS (TREE_CODE (expr)))
{
case tcc_binary:
TREE_OPERAND (expr, 1) = vn_valueize (TREE_OPERAND (expr, 1));
/* Fallthru. */
case tcc_unary:
TREE_OPERAND (expr, 0) = vn_valueize (TREE_OPERAND (expr, 0));
break;
default:;
}
return expr;
}
/* Simplify the binary expression RHS, and return the result if /* Simplify the binary expression RHS, and return the result if
simplified. */ simplified. */
...@@ -3250,7 +3230,7 @@ simplify_binary_expression (gimple stmt) ...@@ -3250,7 +3230,7 @@ simplify_binary_expression (gimple stmt)
if (VN_INFO (op0)->has_constants if (VN_INFO (op0)->has_constants
|| TREE_CODE_CLASS (code) == tcc_comparison || TREE_CODE_CLASS (code) == tcc_comparison
|| code == COMPLEX_EXPR) || code == COMPLEX_EXPR)
op0 = valueize_expr (vn_get_expr_for (op0)); op0 = vn_get_expr_for (op0);
else else
op0 = vn_valueize (op0); op0 = vn_valueize (op0);
} }
...@@ -3259,7 +3239,7 @@ simplify_binary_expression (gimple stmt) ...@@ -3259,7 +3239,7 @@ simplify_binary_expression (gimple stmt)
{ {
if (VN_INFO (op1)->has_constants if (VN_INFO (op1)->has_constants
|| code == COMPLEX_EXPR) || code == COMPLEX_EXPR)
op1 = valueize_expr (vn_get_expr_for (op1)); op1 = vn_get_expr_for (op1);
else else
op1 = vn_valueize (op1); op1 = vn_valueize (op1);
} }
...@@ -3321,7 +3301,7 @@ simplify_unary_expression (gimple stmt) ...@@ -3321,7 +3301,7 @@ simplify_unary_expression (gimple stmt)
orig_op0 = op0; orig_op0 = op0;
if (VN_INFO (op0)->has_constants) if (VN_INFO (op0)->has_constants)
op0 = valueize_expr (vn_get_expr_for (op0)); op0 = vn_get_expr_for (op0);
else if (CONVERT_EXPR_CODE_P (code) else if (CONVERT_EXPR_CODE_P (code)
|| code == REALPART_EXPR || code == REALPART_EXPR
|| code == IMAGPART_EXPR || code == IMAGPART_EXPR
...@@ -3330,7 +3310,7 @@ simplify_unary_expression (gimple stmt) ...@@ -3330,7 +3310,7 @@ simplify_unary_expression (gimple stmt)
{ {
/* We want to do tree-combining on conversion-like expressions. /* We want to do tree-combining on conversion-like expressions.
Make sure we feed only SSA_NAMEs or constants to fold though. */ Make sure we feed only SSA_NAMEs or constants to fold though. */
tree tem = valueize_expr (vn_get_expr_for (op0)); tree tem = vn_get_expr_for (op0);
if (UNARY_CLASS_P (tem) if (UNARY_CLASS_P (tem)
|| BINARY_CLASS_P (tem) || BINARY_CLASS_P (tem)
|| TREE_CODE (tem) == VIEW_CONVERT_EXPR || TREE_CODE (tem) == VIEW_CONVERT_EXPR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment