tree-optimization/95679 - properly signal changes from propagate_into_phi_args

This restores a lost setting of something_changed with the
recent refactoring of the substitute and fold engine.  The
reported ICE in the PR was meanwhile mitigated in other ways
but the issue can still result in missed optimizations via
failed runs of CFG cleanup.

2020-07-29  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/95679
	* tree-ssa-propagate.h
	(substitute_and_fold_engine::propagate_into_phi_args): Return
	whether anything changed.
	* tree-ssa-propagate.c
	(substitute_and_fold_engine::propagate_into_phi_args): Likewise.
	(substitute_and_fold_dom_walker::before_dom_children): Update
	something_changed.
This commit is contained in:
Richard Biener 2020-07-29 09:59:01 +02:00
parent 6de5600a8b
commit 8e8792a347
2 changed files with 12 additions and 5 deletions

View File

@ -1017,11 +1017,13 @@ substitute_and_fold_dom_walker::foreach_new_stmt_in_bb
}
}
void
bool
substitute_and_fold_engine::propagate_into_phi_args (basic_block bb)
{
edge e;
edge_iterator ei;
bool propagated = false;
/* Visit BB successor PHI nodes and replace PHI args. */
FOR_EACH_EDGE (e, ei, bb->succs)
{
@ -1035,11 +1037,16 @@ substitute_and_fold_engine::propagate_into_phi_args (basic_block bb)
|| virtual_operand_p (arg))
continue;
tree val = get_value (arg, phi);
if (val && is_gimple_min_invariant (val)
if (val
&& is_gimple_min_invariant (val)
&& may_propagate_copy (arg, val))
propagate_value (use_p, val);
{
propagate_value (use_p, val);
propagated = true;
}
}
}
return propagated;
}
edge
@ -1229,7 +1236,7 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
}
}
substitute_and_fold_engine->propagate_into_phi_args (bb);
something_changed |= substitute_and_fold_engine->propagate_into_phi_args (bb);
return NULL;
}

View File

@ -115,7 +115,7 @@ class substitute_and_fold_engine
virtual void pre_fold_stmt (gimple *) { }
virtual void post_new_stmt (gimple *) { }
void propagate_into_phi_args (basic_block);
bool propagate_into_phi_args (basic_block);
/* Users like VRP can set this when they want to perform
folding for every propagation. */