ipa-cp: Do not be too optimistic about self-recursive edges (PR 107661)
authorMartin Jambor <mjambor@suse.cz>
Tue, 22 Nov 2022 17:22:03 +0000 (18:22 +0100)
committerMartin Jambor <mjambor@suse.cz>
Tue, 22 Nov 2022 17:28:44 +0000 (18:28 +0100)
commitc4a92a9117a034e7cf291ae51d8b9b844fb5a88b
tree79d3a5576878f91a4f881e3c6085adc773e7fa23
parentd6bbca7b78745915d98bb1324d79de6a1e6dc801
ipa-cp: Do not be too optimistic about self-recursive edges (PR 107661)

PR 107661 shows that function push_agg_values_for_index_from_edge
should not attempt to optimize self-recursive call graph edges when
called from cgraph_edge_brings_all_agg_vals_for_node.  Unlike when
being called from find_aggregate_values_for_callers_subset, we cannot
expect that any cloning for constants would lead to the edge leading
from a new clone to the same new clone, in this case it would only be
redirected to a new callee.

Fixed by adding a parameter to push_agg_values_from_edge whether being
optimistic about self-recursive edges is possible.

gcc/ChangeLog:

2022-11-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/107661
* ipa-cp.cc (push_agg_values_from_edge): New parameter
optimize_self_recursion, use it to decide whether to pass interim to
the helper function.
(find_aggregate_values_for_callers_subset): Pass true in the new
parameter of push_agg_values_from_edge.
(cgraph_edge_brings_all_agg_vals_for_node): Pass false in the new
parameter of push_agg_values_from_edge.

gcc/testsuite/ChangeLog:

2022-11-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/107661
* g++.dg/ipa/pr107661.C: New test.
gcc/ipa-cp.cc
gcc/testsuite/g++.dg/ipa/pr107661.C [new file with mode: 0644]