Inline functions with builtin_constant_p more agressively.
authorJan Hubicka <jh@suse.cz>
Wed, 21 Oct 2020 18:00:22 +0000 (20:00 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 21 Oct 2020 18:00:22 +0000 (20:00 +0200)
commitcaaa218f912ccf932fdb79243ded68bb462bbe63
tree759306f33556c3c19d797f001e97e016717d3296
parent6bd2f2d080c52b73edac7dcb9fa9dcb58e6170bb
Inline functions with builtin_constant_p more agressively.

This patch implements heuristics that increases inline limits (by the hints
mechanism) for inline functions that use builtin_constant_p on parameter. Those
are very likely intended to be always inlined and simplify after inlining.

The PR is about a function that we used to inline with
 --param inline-insns-single=200 but with new default of 70 for -O2 we no longer
do so.  Hints are currently configured to bump the bound up twice, so we
get limit of 140 that is still not enough to inline the particular testcase
but it should help in general.  I can implement a stronger bump if that seems
useful (maybe it is). The example is bit operation written as a decision chain
with 64 conditions.
This blows up the limit on number of conditions we track per funtion (which is
30) and thus the size/time estimates are not working that well.

gcc/ChangeLog:

PR ipa/97445
* ipa-fnsummary.c (ipa_dump_hints): Add INLINE_HINT_builtin_constant_p.
(ipa_fn_summary::~ipa_fn_summary): Free builtin_constant_p_parms.
(ipa_fn_summary_t::duplicate): Duplicate builtin_constant_p_parms.
(ipa_dump_fn_summary): Dump builtin_constant_p_parms.
(add_builtin_constant_p_parm): New function
(set_cond_stmt_execution_predicate): Update builtin_constant_p_parms.
(ipa_call_context::estimate_size_and_time): Set
INLINE_HINT_builtin_constant_p..
(ipa_merge_fn_summary_after_inlining): Merge builtin_constant_p_parms.
(inline_read_section): Read builtin_constant_p_parms.
(ipa_fn_summary_write): Write builtin_constant_p_parms.
* ipa-fnsummary.h (enum ipa_hints_vals): Add
INLINE_HINT_builtin_constant_p.
* ipa-inline.c (want_inline_small_function_p): Use
INLINE_HINT_builtin_constant_p.
(edge_badness): Use INLINE_HINT_builtin_constant_p.

gcc/testsuite/ChangeLog:

PR ipa/97445
* gcc.dg/ipa/inlinehint-5.c: New test.
gcc/ipa-fnsummary.c
gcc/ipa-fnsummary.h
gcc/ipa-inline.c
gcc/testsuite/gcc.dg/ipa/inlinehint-5.c [new file with mode: 0644]