Commit 8d7437be by Jeff Law Committed by Jeff Law

re PR tree-optimization/71437 (Performance regression after r235817)

	PR tree-optimization/71437
	* tree-ssa-dom.c (pfn_simplify): Add basic_block argument.  All
	callers changed.
	(simplify_stmt_for_jump_threading): Add basic_block argument.  All
	callers changed.
	(lhs_of_dominating_assert): Moved from here into tree-vrp.c.
	(dom_opt_dom_walker::thread_across_edge): Remove
	handle_dominating_asserts argument.  All callers changed.
	(record_temporary_equivalences_from_stmts_at_dest): Corresponding
	changes.  Remove calls to lhs_of_dominating_assert.  Other
	uses of handle_dominating_asserts turn into unconditional code
	(simplify_control_stmt_condition_1): Likewise.
	(simplify_control_stmt_condition): Likewise.
	(thread_through_normal_block, thread_across_edge): Likewise.
	* tree-ssa-threadedge.h (thread_across_edge): Corresponding changes.
	* tree-vrp.c (lhs_of_dominating_assert): Move here.  Return original
	object if it is not an SSA_NAME.
	(simplify_stmt_for_jump_threading): Call lhs_of_dominating_assert
	before calling into the VRP specific simplifiers.
	(identify_jump_threads): Remove handle_dominating_asserts
	argument.

From-SVN: r246207
parent 9fc900af
2017-03-16 Jeff Law <law@redhat.com>
PR tree-optimization/71437
* tree-ssa-dom.c (pfn_simplify): Add basic_block argument. All
callers changed.
(simplify_stmt_for_jump_threading): Add basic_block argument. All
callers changed.
(lhs_of_dominating_assert): Moved from here into tree-vrp.c.
(dom_opt_dom_walker::thread_across_edge): Remove
handle_dominating_asserts argument. All callers changed.
(record_temporary_equivalences_from_stmts_at_dest): Corresponding
changes. Remove calls to lhs_of_dominating_assert. Other
uses of handle_dominating_asserts turn into unconditional code
(simplify_control_stmt_condition_1): Likewise.
(simplify_control_stmt_condition): Likewise.
(thread_through_normal_block, thread_across_edge): Likewise.
* tree-ssa-threadedge.h (thread_across_edge): Corresponding changes.
* tree-vrp.c (lhs_of_dominating_assert): Move here. Return original
object if it is not an SSA_NAME.
(simplify_stmt_for_jump_threading): Call lhs_of_dominating_assert
before calling into the VRP specific simplifiers.
(identify_jump_threads): Remove handle_dominating_asserts
argument.
2017-03-16 Jakub Jelinek <jakub@redhat.com>
PR fortran/79886
......
......@@ -604,7 +604,8 @@ make_pass_dominator (gcc::context *ctxt)
static tree
simplify_stmt_for_jump_threading (gimple *stmt,
gimple *within_stmt ATTRIBUTE_UNUSED,
class avail_exprs_stack *avail_exprs_stack)
class avail_exprs_stack *avail_exprs_stack,
basic_block bb ATTRIBUTE_UNUSED)
{
return avail_exprs_stack->lookup_avail_expr (stmt, false, true);
}
......@@ -835,7 +836,7 @@ dom_opt_dom_walker::thread_across_edge (edge e)
/* With all the edge equivalences in the tables, go ahead and attempt
to thread through E->dest. */
::thread_across_edge (m_dummy_cond, e, false,
::thread_across_edge (m_dummy_cond, e,
m_const_and_copies, m_avail_exprs_stack,
simplify_stmt_for_jump_threading);
......
......@@ -30,10 +30,10 @@ extern void threadedge_initialize_values (void);
extern void threadedge_finalize_values (void);
extern bool potentially_threadable_block (basic_block);
extern void propagate_threaded_block_debug_into (basic_block, basic_block);
extern void thread_across_edge (gcond *, edge, bool,
extern void thread_across_edge (gcond *, edge,
const_and_copies *,
avail_exprs_stack *,
tree (*) (gimple *, gimple *,
avail_exprs_stack *));
avail_exprs_stack *, basic_block));
#endif /* GCC_TREE_SSA_THREADEDGE_H */
......@@ -10749,6 +10749,33 @@ vrp_fold_stmt (gimple_stmt_iterator *si)
/* Unwindable const/copy equivalences. */
const_and_copies *equiv_stack;
/* Return the LHS of any ASSERT_EXPR where OP appears as the first
argument to the ASSERT_EXPR and in which the ASSERT_EXPR dominates
BB. If no such ASSERT_EXPR is found, return OP. */
static tree
lhs_of_dominating_assert (tree op, basic_block bb, gimple *stmt)
{
imm_use_iterator imm_iter;
gimple *use_stmt;
use_operand_p use_p;
if (TREE_CODE (op) == SSA_NAME)
{
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, op)
{
use_stmt = USE_STMT (use_p);
if (use_stmt != stmt
&& gimple_assign_single_p (use_stmt)
&& TREE_CODE (gimple_assign_rhs1 (use_stmt)) == ASSERT_EXPR
&& TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == op
&& dominated_by_p (CDI_DOMINATORS, bb, gimple_bb (use_stmt)))
return gimple_assign_lhs (use_stmt);
}
}
return op;
}
/* A trivial wrapper so that we can present the generic jump threading
code with a simple API for simplifying statements. STMT is the
statement we want to simplify, WITHIN_STMT provides the location
......@@ -10756,13 +10783,20 @@ const_and_copies *equiv_stack;
static tree
simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt,
class avail_exprs_stack *avail_exprs_stack ATTRIBUTE_UNUSED)
class avail_exprs_stack *avail_exprs_stack ATTRIBUTE_UNUSED,
basic_block bb)
{
if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
return vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
gimple_cond_lhs (cond_stmt),
gimple_cond_rhs (cond_stmt),
within_stmt);
{
tree op0 = gimple_cond_lhs (cond_stmt);
op0 = lhs_of_dominating_assert (op0, bb, stmt);
tree op1 = gimple_cond_rhs (cond_stmt);
op1 = lhs_of_dominating_assert (op1, bb, stmt);
return vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
op0, op1, within_stmt);
}
/* We simplify a switch statement by trying to determine which case label
will be taken. If we are successful then we return the corresponding
......@@ -10773,6 +10807,8 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt,
if (TREE_CODE (op) != SSA_NAME)
return NULL_TREE;
op = lhs_of_dominating_assert (op, bb, stmt);
value_range *vr = get_value_range (op);
if ((vr->type != VR_RANGE && vr->type != VR_ANTI_RANGE)
|| symbolic_range_p (vr))
......@@ -10948,7 +10984,7 @@ identify_jump_threads (void)
if (e->flags & (EDGE_IGNORE | EDGE_COMPLEX))
continue;
thread_across_edge (dummy, e, true, equiv_stack, NULL,
thread_across_edge (dummy, e, equiv_stack, NULL,
simplify_stmt_for_jump_threading);
}
}
......
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