Thanks for the review and the inputs, Richard Biener. The `-finline-as=` option is an interesting.
However, this PR specifically aims to make these `-O3` inline params to be available under some `-f` option, similar to some of the existing inline options. On 6/24/24, 6:28 AM, "Richard Biener" <richard.guent...@gmail.com <mailto:richard.guent...@gmail.com>> wrote: CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. On Mon, Jun 24, 2024 at 1:18 PM Malladi, Rama <rvmal...@amazon.com <mailto:rvmal...@amazon.com>> wrote: > > From: Rama Malladi <rvmal...@amazon.com <mailto:rvmal...@amazon.com>> Hmm, if we offer the ability to set -O3 inline limits why wouldn't we offer a way to set -O2 inline limits for example with -O3? So ... wouldn't a -finline-limit={default,O2,O3} option be a more generic and extensible way to achieve what the patch does? Yeah, it conflicts somewhat with the existing -finline-limit[-=] flags, so possibly another name (-finline-as=O3?) is needed. Richard. > Signed-off-by: Rama Malladi <rvmal...@amazon.com <mailto:rvmal...@amazon.com>> > --- > gcc/common.opt | 5 +++++ > gcc/doc/invoke.texi | 18 +++++++++++++----- > gcc/opts.cc | 17 ++++++++++++----- > 3 files changed, 30 insertions(+), 10 deletions(-) > > diff --git a/gcc/common.opt b/gcc/common.opt > index f2bc47fdc5e..ce95175c1e4 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1961,6 +1961,11 @@ finline-functions-called-once > Common Var(flag_inline_functions_called_once) Optimization > Integrate functions only required by their single caller. > > +finline-functions-aggressive > +Common Var(flag_inline_functions_aggressive) Init(0) Optimization > +Aggressively integrate functions not declared \"inline\" into their callers > when profitable. > +This option selects the same inlining heuristics as \"-O3\". > + > finline-limit- > Common RejectNegative Joined Alias(finline-limit=) > > diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi > index c790e2f3518..7dc5c5ab433 100644 > --- a/gcc/doc/invoke.texi > +++ b/gcc/doc/invoke.texi > @@ -570,8 +570,8 @@ Objective-C and Objective-C++ Dialects}. > -fgcse-sm -fhoist-adjacent-loads -fif-conversion > -fif-conversion2 -findirect-inlining > -finline-stringops[=@var{fn}] > --finline-functions -finline-functions-called-once -finline-limit=@var{n} > --finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone > +-finline-functions -finline-functions-aggressive > -finline-functions-called-once > +-finline-limit=@var{n} -finline-small-functions -fipa-modref -fipa-cp > -fipa-cp-clone > -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const > -fipa-reference -fipa-reference-addressable > -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} > @@ -12625,9 +12625,9 @@ designed to reduce code size. > Disregard strict standards compliance. @option{-Ofast} enables all > @option{-O3} optimizations. It also enables optimizations that are not > valid for all standard-compliant programs. > -It turns on @option{-ffast-math}, @option{-fallow-store-data-races} > -and the Fortran-specific @option{-fstack-arrays}, unless > -@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. > +It turns on @option{-ffast-math}, @option{-finline-functions-aggressive}, > +@option{-fallow-store-data-races} and the Fortran-specific > @option{-fstack-arrays}, > +unless @option{-fmax-stack-var-size} is specified, and > @option{-fno-protect-parens}. > It turns off @option{-fsemantic-interposition}. > > @opindex Og > @@ -12793,6 +12793,14 @@ assembler code in its own right. > Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled > by @option{-fprofile-use} and @option{-fauto-profile}. > > +@opindex finline-functions-aggressive > +@item -finline-functions-aggressive > +Aggressively integrate functions not declared @code{inline} into their > callers when > +profitable. This option selects the same inlining heuristics as @option{-O3}. > + > +Enabled at levels @option{-O3}, @option{-Ofast}, but not @option{-Og}, > +@option{-O1}, @option{-O2}, @option{-Os}. > + > @opindex finline-functions-called-once > @item -finline-functions-called-once > Consider all @code{static} functions called once for inlining into their > diff --git a/gcc/opts.cc b/gcc/opts.cc > index 1b1b46455af..729f2831e67 100644 > --- a/gcc/opts.cc > +++ b/gcc/opts.cc > @@ -700,11 +700,7 @@ static const struct default_options > default_options_table[] = > { OPT_LEVELS_3_PLUS, OPT_fversion_loops_for_strides, NULL, 1 }, > > /* -O3 parameters. */ > - { OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_auto_, NULL, 30 }, > - { OPT_LEVELS_3_PLUS, OPT__param_early_inlining_insns_, NULL, 14 }, > - { OPT_LEVELS_3_PLUS, OPT__param_inline_heuristics_hint_percent_, NULL, 600 > }, > - { OPT_LEVELS_3_PLUS, OPT__param_inline_min_speedup_, NULL, 15 }, > - { OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_single_, NULL, 200 }, > + { OPT_LEVELS_3_PLUS, OPT_finline_functions_aggressive, NULL, 1 }, > > /* -Ofast adds optimizations to -O3. */ > { OPT_LEVELS_FAST, OPT_ffast_math, NULL, 1 }, > @@ -3037,6 +3033,17 @@ common_handle_option (struct gcc_options *opts, > value / 2); > break; > > + case OPT_finline_functions_aggressive: > + if(opts->x_flag_inline_functions_aggressive) > + { > + opts->x_param_max_inline_insns_auto = 30; > + opts->x_param_early_inlining_insns = 14; > + opts->x_param_inline_heuristics_hint_percent = 600; > + opts->x_param_inline_min_speedup = 15; > + opts->x_param_max_inline_insns_single = 200; > + } > + break; > + > case OPT_finstrument_functions_exclude_function_list_: > add_comma_separated_to_vector > (&opts->x_flag_instrument_functions_exclude_functions, arg); > -- > 2.45.1 >