On 11/20/20 12:41 PM, Martin Jambor wrote:
> Hi,
>
> this is an updated patch based on our conversation on IRC today.  So far
> I have had a look at the effects on only tramp3d and although it makes
> the heuristics more pessimistic more times than optimistic (number of
> clones at -Ofast drops from 559 to 557), there are also lattices which
> are massively boosted.
I don't think that's inherently a bad thing.

>
> When looking at the testcase of PR 97816 I realized that the reason
> why we were hitting overflows in size growth estimates in IPA-CP is
> not because the chains of how lattices feed values to each other are
> so long but mainly because we add estimates in callee lattices to
> caller lattices for each value source, which roughly corresponds to a
> call graph edge, and therefore if there are multiple calls between two
> functions passing the same value in a parameter we end up doing it
> more than once, sometimes actually quite many times.
>
> This patch avoids it by using a has_set to remember the source values
> we have already updated and not increasing their size again.
> Furhtermore, to improve estimation of times we scale the propagated
> time benefits with edge frequencies as we accumulate them.
>
> This should make any overflows very unlikely but not impossible, so I
> still included checks for overflows but decided to restructure the
> code to only need it in the propagate_effects function and modified it
> so that it does not need to perform the check before each sum.
>
> This is because I decided to add local estimates to propagated
> estimates already in propagate_effects and not at the evaluation time.
> The function can then do the sums in a wide type and discard them in
> the unlikely case of an overflow.  I also decided to use the
> opportunity to make propagated effect stats now include stats from
> other values in the same SCCs.  In the dumps I have seen this tended
> to increase size cost a tiny bit more than the estimated time benefit
> but both increases were small.
>
> Bootstrapped and LTO bootstrapped on x86_64-linux.  OK for trunk?
>
> Thanks,
>
> Martin
>
>
> gcc/ChangeLog:
>
> 2020-11-20  Martin Jambor  <mjam...@suse.cz>
>
>       PR ipa/97816
>       * ipa-cp.c (safe_add): Removed.
>       (good_cloning_opportunity_p): Remove special handling of INT_MAX.
>       (value_topo_info<valtype>::propagate_effects): Take care not to
>       propagate from size one value to another through more sources.  Scale
>       propagated times with edge frequencies.  Include local time and size
>       in propagates ones here.  Take care not to overflow size.
>       (decide_about_value): Do not add local and propagated effects when
>       passing them to good_cloning_opportunity_p.
OK
Jeff

Reply via email to