Commit 91bc6112 by Richard Guenther Committed by Richard Biener

tree-ssa-forwprop.c (combine_conversions): Return whether we have to run cfg-cleanup.

2011-07-21  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-forwprop.c (combine_conversions): Return whether
	we have to run cfg-cleanup.  Properly remove dead stmts.
	(ssa_forward_propagate_and_combine): Adjust.

From-SVN: r176561
parent 2224b91a
2011-07-21 Richard Guenther <rguenther@suse.de>
* tree-ssa-forwprop.c (combine_conversions): Return whether
we have to run cfg-cleanup. Properly remove dead stmts.
(ssa_forward_propagate_and_combine): Adjust.
2011-07-21 Richard Sandiford <richard.sandiford@linaro.org> 2011-07-21 Richard Sandiford <richard.sandiford@linaro.org>
* regcprop.c (maybe_mode_change): Check HARD_REGNO_MODE_OK. * regcprop.c (maybe_mode_change): Check HARD_REGNO_MODE_OK.
......
...@@ -2144,9 +2144,10 @@ out: ...@@ -2144,9 +2144,10 @@ out:
} }
/* Combine two conversions in a row for the second conversion at *GSI. /* Combine two conversions in a row for the second conversion at *GSI.
Returns true if there were any changes made. */ Returns 1 if there were any changes made, 2 if cfg-cleanup needs to
run. Else it returns 0. */
static bool static int
combine_conversions (gimple_stmt_iterator *gsi) combine_conversions (gimple_stmt_iterator *gsi)
{ {
gimple stmt = gsi_stmt (*gsi); gimple stmt = gsi_stmt (*gsi);
...@@ -2163,15 +2164,15 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2163,15 +2164,15 @@ combine_conversions (gimple_stmt_iterator *gsi)
if (useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (op0))) if (useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (op0)))
{ {
gimple_assign_set_rhs_code (stmt, TREE_CODE (op0)); gimple_assign_set_rhs_code (stmt, TREE_CODE (op0));
return true; return 1;
} }
if (TREE_CODE (op0) != SSA_NAME) if (TREE_CODE (op0) != SSA_NAME)
return false; return 0;
def_stmt = SSA_NAME_DEF_STMT (op0); def_stmt = SSA_NAME_DEF_STMT (op0);
if (!is_gimple_assign (def_stmt)) if (!is_gimple_assign (def_stmt))
return false; return 0;
if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))) if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
{ {
...@@ -2210,7 +2211,7 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2210,7 +2211,7 @@ combine_conversions (gimple_stmt_iterator *gsi)
gimple_assign_set_rhs1 (stmt, unshare_expr (defop0)); gimple_assign_set_rhs1 (stmt, unshare_expr (defop0));
gimple_assign_set_rhs_code (stmt, TREE_CODE (defop0)); gimple_assign_set_rhs_code (stmt, TREE_CODE (defop0));
update_stmt (stmt); update_stmt (stmt);
return true; return remove_prop_source_from_use (op0) ? 2 : 1;
} }
/* Likewise, if the intermediate and initial types are either both /* Likewise, if the intermediate and initial types are either both
...@@ -2232,7 +2233,7 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2232,7 +2233,7 @@ combine_conversions (gimple_stmt_iterator *gsi)
{ {
gimple_assign_set_rhs1 (stmt, defop0); gimple_assign_set_rhs1 (stmt, defop0);
update_stmt (stmt); update_stmt (stmt);
return true; return remove_prop_source_from_use (op0) ? 2 : 1;
} }
/* If we have a sign-extension of a zero-extended value, we can /* If we have a sign-extension of a zero-extended value, we can
...@@ -2243,7 +2244,7 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2243,7 +2244,7 @@ combine_conversions (gimple_stmt_iterator *gsi)
{ {
gimple_assign_set_rhs1 (stmt, defop0); gimple_assign_set_rhs1 (stmt, defop0);
update_stmt (stmt); update_stmt (stmt);
return true; return remove_prop_source_from_use (op0) ? 2 : 1;
} }
/* Two conversions in a row are not needed unless: /* Two conversions in a row are not needed unless:
...@@ -2272,7 +2273,7 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2272,7 +2273,7 @@ combine_conversions (gimple_stmt_iterator *gsi)
{ {
gimple_assign_set_rhs1 (stmt, defop0); gimple_assign_set_rhs1 (stmt, defop0);
update_stmt (stmt); update_stmt (stmt);
return true; return remove_prop_source_from_use (op0) ? 2 : 1;
} }
/* A truncation to an unsigned type should be canonicalized as /* A truncation to an unsigned type should be canonicalized as
...@@ -2296,11 +2297,11 @@ combine_conversions (gimple_stmt_iterator *gsi) ...@@ -2296,11 +2297,11 @@ combine_conversions (gimple_stmt_iterator *gsi)
else else
gimple_assign_set_rhs_from_tree (gsi, tem); gimple_assign_set_rhs_from_tree (gsi, tem);
update_stmt (gsi_stmt (*gsi)); update_stmt (gsi_stmt (*gsi));
return true; return 1;
} }
} }
return false; return 0;
} }
/* Main entry point for the forward propagation and statement combine /* Main entry point for the forward propagation and statement combine
...@@ -2462,7 +2463,12 @@ ssa_forward_propagate_and_combine (void) ...@@ -2462,7 +2463,12 @@ ssa_forward_propagate_and_combine (void)
else if (CONVERT_EXPR_CODE_P (code) else if (CONVERT_EXPR_CODE_P (code)
|| code == FLOAT_EXPR || code == FLOAT_EXPR
|| code == FIX_TRUNC_EXPR) || code == FIX_TRUNC_EXPR)
changed = combine_conversions (&gsi); {
int did_something = combine_conversions (&gsi);
if (did_something == 2)
cfg_changed = true;
changed = did_something != 0;
}
break; break;
} }
......
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