public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add -finline-functions-aggressive option [PR114531]
       [not found] <20240621172913.23491-1-rvmallad@amazon.com>
@ 2024-06-24 11:17 ` Malladi, Rama
  2024-06-24 11:27   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Malladi, Rama @ 2024-06-24 11:17 UTC (permalink / raw)
  To: gcc-patches
  Cc: jgreenhalgh, hp, pinskia, hubicka, rsandifo, Abdul, Nafees Ahmed

From: Rama Malladi <rvmallad@amazon.com>

Signed-off-by: Rama Malladi <rvmallad@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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add -finline-functions-aggressive option [PR114531]
  2024-06-24 11:17 ` [PATCH] Add -finline-functions-aggressive option [PR114531] Malladi, Rama
@ 2024-06-24 11:27   ` Richard Biener
  2024-06-25 18:34     ` Malladi, Rama
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2024-06-24 11:27 UTC (permalink / raw)
  To: Malladi, Rama
  Cc: gcc-patches, jgreenhalgh, hp, pinskia, hubicka, rsandifo, Abdul,
	Nafees Ahmed

On Mon, Jun 24, 2024 at 1:18 PM Malladi, Rama <rvmallad@amazon.com> wrote:
>
> From: Rama Malladi <rvmallad@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 <rvmallad@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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add -finline-functions-aggressive option [PR114531]
  2024-06-24 11:27   ` Richard Biener
@ 2024-06-25 18:34     ` Malladi, Rama
  0 siblings, 0 replies; 3+ messages in thread
From: Malladi, Rama @ 2024-06-25 18:34 UTC (permalink / raw)
  To: Richard Biener
  Cc: gcc-patches, jgreenhalgh, hp, pinskia, hubicka, rsandifo, Abdul,
	Nafees Ahmed

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.guenther@gmail.com <mailto:richard.guenther@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 <rvmallad@amazon.com <mailto:rvmallad@amazon.com>> wrote:
>
> From: Rama Malladi <rvmallad@amazon.com <mailto:rvmallad@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 <rvmallad@amazon.com <mailto:rvmallad@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
>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-25 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240621172913.23491-1-rvmallad@amazon.com>
2024-06-24 11:17 ` [PATCH] Add -finline-functions-aggressive option [PR114531] Malladi, Rama
2024-06-24 11:27   ` Richard Biener
2024-06-25 18:34     ` Malladi, Rama

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).