https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107661
--- Comment #14 from Martin Jambor <jamborm at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #13)
> It seems to have something to do with
> push_agg_values_from_edge()/push_agg_values_for_index_from_edge() behaviour
> of filtering self-recursive lattice values:
>
> if (interim && self_recursive_pass_through_p (cs, jfunc, index))
> {
> interim->push_adjusted_values (src_idx, index, unit_delta,
> res);
> return;
> }
Spot on.
>
> Here we seem to ignore lattice values discovered on the edges and only copy
> already encountered values. But we only populate 'interim' with values we
> specialised the self-recursive call against:
>
> push_agg_values_from_edge (cs, dest_info, &edge_values, &existing);
>
> ('existing' variable is populated by values caller uses in one location).
>
>
> The following hack seems to fix the test case for me but I suspect it just
> breaks any self-recursive propagation:
No, it does not. The self-recursive hack, I mean feature, is meant to
be used when push_agg_values_from_edge is called from
find_aggregate_values_for_callers_subset. At that point we can assume
we would change both the caller and the callee. But when it is called
from cgraph_edge_brings_all_agg_vals_for_node it is not the right
thing to do because it potentially leads only to redirection to a
different callee.
Correctness-wise your patch is a valid fix. But it would disable to
computation avoidance code in push_agg_values_from_edge and so I'll
propose a patch adding a parameter to push_agg_values_from_edge and
its helper signaling whether they can be optimistic about
self-recursive edges.
Thank you for reporting and a very nice test-case.