Commit a25454ea by Richard Biener Committed by Richard Biener

match.pd: Implement pattern from simplify_mult.

2014-11-10  Richard Biener  <rguenther@suse.de>

	* match.pd: Implement pattern from simplify_mult.
	* tree-ssa-forwprop.c (simplify_mult): Remove.
	(pass_forwprop::execute): Do not call simplify_mult.

From-SVN: r217290
parent 6be4c4ec
2014-11-10 Richard Biener <rguenther@suse.de>
* match.pd: Implement pattern from simplify_mult.
* tree-ssa-forwprop.c (simplify_mult): Remove.
(pass_forwprop::execute): Do not call simplify_mult.
2014-11-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/63800
* tree-ssa-pre.c (eliminate_push_avail): Push in a way so
we can restore the previous availability in after_dom_children.
......@@ -443,3 +443,11 @@ along with GCC; see the file COPYING3. If not see
&& operand_equal_p (@1, build_low_bits_mask (TREE_TYPE (@1),
TYPE_PRECISION (type)), 0))
(convert @0)))
/* (X /[ex] A) * A -> X. */
(simplify
(mult (convert? (exact_div @0 @1)) @1)
/* Look through a sign-changing conversion. */
(if (TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (type))
(convert @0)))
......@@ -2588,54 +2588,6 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
return true;
}
/* Simplify multiplications.
Return true if a transformation applied, otherwise return false. */
static bool
simplify_mult (gimple_stmt_iterator *gsi)
{
gimple stmt = gsi_stmt (*gsi);
tree arg1 = gimple_assign_rhs1 (stmt);
tree arg2 = gimple_assign_rhs2 (stmt);
if (TREE_CODE (arg1) != SSA_NAME)
return false;
gimple def_stmt = SSA_NAME_DEF_STMT (arg1);
if (!is_gimple_assign (def_stmt))
return false;
/* Look through a sign-changing conversion. */
if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
{
if (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (def_stmt)))
!= TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt)))
|| TREE_CODE (gimple_assign_rhs1 (def_stmt)) != SSA_NAME)
return false;
def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt));
if (!is_gimple_assign (def_stmt))
return false;
}
if (gimple_assign_rhs_code (def_stmt) == EXACT_DIV_EXPR)
{
if (operand_equal_p (gimple_assign_rhs2 (def_stmt), arg2, 0))
{
tree res = gimple_assign_rhs1 (def_stmt);
if (useless_type_conversion_p (TREE_TYPE (arg1), TREE_TYPE (res)))
gimple_assign_set_rhs_with_ops (gsi, TREE_CODE (res), res,
NULL_TREE);
else
gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, res, NULL_TREE);
gcc_assert (gsi_stmt (*gsi) == stmt);
update_stmt (stmt);
return true;
}
}
return false;
}
/* Primitive "lattice" function for gimple_simplify. */
......@@ -2853,13 +2805,6 @@ pass_forwprop::execute (function *fun)
|| code == BIT_XOR_EXPR)
&& simplify_rotate (&gsi))
changed = true;
else if (code == MULT_EXPR)
{
changed = simplify_mult (&gsi);
if (changed
&& maybe_clean_or_replace_eh_stmt (stmt, stmt))
bitmap_set_bit (to_purge, bb->index);
}
else if (code == PLUS_EXPR
|| code == MINUS_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