From: Richard Biener <rguenther@suse.de>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Add -falign-all-functions
Date: Thu, 18 Jan 2024 11:33:20 +0100 (CET) [thread overview]
Message-ID: <10nqoq23-98s9-p9n4-rnp9-01n5np9051q8@fhfr.qr> (raw)
In-Reply-To: <Zaf33f-doWcUSHHE@kam.mff.cuni.cz>
On Wed, 17 Jan 2024, Jan Hubicka wrote:
> > On Wed, 17 Jan 2024, Jan Hubicka wrote:
> >
> > > >
> > > > I meant the new option might be named -fmin-function-alignment=
> > > > rather than -falign-all-functions because of how it should
> > > > override all other options.
> > >
> > > I was also pondering about both names. -falign-all-functions has the
> > > advantage that it is similar to all the other alignment flags that are
> > > all called -falign-XXX
> > >
> > > but both options are finte for me.
> > > >
> > > > Otherwise is there an updated patch to look at?
> > >
> > > I will prepare one. So shall I drop the max-skip support for alignment
> > > and rename the flag?
> >
> > Yes.
> OK, here is updated version.
> Bootstrapped/regtested on x86_64-linux, OK?
>
> gcc/ChangeLog:
>
> * common.opt (flimit-function-alignment): Reorder so file is
> alphabetically ordered.
> (flimit-function-alignment): New flag.
fmin-function-alignment
OK with that change.
Thanks,
Richard.
> * doc/invoke.texi (-fmin-function-alignment): Document
> (-falign-jumps,-falign-labels): Document that this is an optimization
> bypassed in cold code.
> * varasm.cc (assemble_start_function): Honor -fmin-function-alignment.
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 5f0a101bccb..6e85853f086 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -1040,9 +1040,6 @@ Align the start of functions.
> falign-functions=
> Common RejectNegative Joined Var(str_align_functions) Optimization
>
> -flimit-function-alignment
> -Common Var(flag_limit_function_alignment) Optimization Init(0)
> -
> falign-jumps
> Common Var(flag_align_jumps) Optimization
> Align labels which are only reached by jumping.
> @@ -2277,6 +2274,10 @@ fmessage-length=
> Common RejectNegative Joined UInteger
> -fmessage-length=<number> Limit diagnostics to <number> characters per line. 0 suppresses line-wrapping.
>
> +fmin-function-alignment=
> +Common Joined RejectNegative UInteger Var(flag_min_function_alignment) Optimization
> +Align the start of every function.
> +
> fmodulo-sched
> Common Var(flag_modulo_sched) Optimization
> Perform SMS based modulo scheduling before the first scheduling pass.
> @@ -2601,6 +2602,9 @@ starts and when the destructor finishes.
> flifetime-dse=
> Common Joined RejectNegative UInteger Var(flag_lifetime_dse) Optimization IntegerRange(0, 2)
>
> +flimit-function-alignment
> +Common Var(flag_limit_function_alignment) Optimization Init(0)
> +
> flive-patching
> Common RejectNegative Alias(flive-patching=,inline-clone) Optimization
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 43fd3c3a3cd..456374d9446 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -546,6 +546,7 @@ Objective-C and Objective-C++ Dialects}.
> -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
> -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
> -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
> +-fmin-function-alignment=[@var{n}]
> -fno-allocation-dce -fallow-store-data-races
> -fassociative-math -fauto-profile -fauto-profile[=@var{path}]
> -fauto-inc-dec -fbranch-probabilities
> @@ -14177,6 +14178,9 @@ Align the start of functions to the next power-of-two greater than or
> equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
> least the first @var{m} bytes of the function can be fetched by the CPU
> without crossing an @var{n}-byte alignment boundary.
> +This is an optimization of code performance and alignment is ignored for
> +functions considered cold. If alignment is required for all functions,
> +use @option{-fmin-function-alignment}.
>
> If @var{m} is not specified, it defaults to @var{n}.
>
> @@ -14240,6 +14244,8 @@ Enabled at levels @option{-O2}, @option{-O3}.
> Align loops to a power-of-two boundary. If the loops are executed
> many times, this makes up for any execution of the dummy padding
> instructions.
> +This is an optimization of code performance and alignment is ignored for
> +loops considered cold.
>
> If @option{-falign-labels} is greater than this value, then its value
> is used instead.
> @@ -14262,6 +14268,8 @@ Enabled at levels @option{-O2}, @option{-O3}.
> Align branch targets to a power-of-two boundary, for branch targets
> where the targets can only be reached by jumping. In this case,
> no dummy operations need be executed.
> +This is an optimization of code performance and alignment is ignored for
> +jumps considered cold.
>
> If @option{-falign-labels} is greater than this value, then its value
> is used instead.
> @@ -14275,6 +14283,14 @@ The maximum allowed @var{n} option value is 65536.
>
> Enabled at levels @option{-O2}, @option{-O3}.
>
> +@opindex fmin-function-alignment=@var{n}
> +@item -fmin-function-alignment
> +Specify minimal alignment of functions to the next power-of-two greater than or
> +equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied
> +also to all functions (even those considered cold). The alignment is also not
> +affected by @option{-flimit-function-alignment}
> +
> +
> @opindex fno-allocation-dce
> @item -fno-allocation-dce
> Do not remove unused C++ allocations in dead code elimination.
> @@ -14371,7 +14387,7 @@ To use the link-time optimizer, @option{-flto} and optimization
> options should be specified at compile time and during the final link.
> It is recommended that you compile all the files participating in the
> same link with the same options and also specify those options at
> -link time.
> +link time.
> For example:
>
> @smallexample
> diff --git a/gcc/varasm.cc b/gcc/varasm.cc
> index d2c879b7da4..ccf97a5a496 100644
> --- a/gcc/varasm.cc
> +++ b/gcc/varasm.cc
> @@ -1939,11 +1939,16 @@ assemble_start_function (tree decl, const char *fnname)
>
> /* Tell assembler to move to target machine's alignment for functions. */
> align = floor_log2 (align / BITS_PER_UNIT);
> + /* Handle forced alignment. This really ought to apply to all functions,
> + since it is used by patchable entries. */
> + if (flag_min_function_alignment && align < flag_min_function_alignment)
> + align = flag_min_function_alignment;
> +
> if (align > 0)
> {
> ASM_OUTPUT_ALIGN (asm_out_file, align);
> }
>
> /* Handle a user-specified function alignment.
> Note that we still need to align to DECL_ALIGN, as above,
> because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
prev parent reply other threads:[~2024-01-18 10:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 14:56 Jan Hubicka
2024-01-08 12:59 ` Richard Biener
2024-01-17 13:12 ` Jan Hubicka
2024-01-17 13:22 ` Richard Biener
2024-01-17 14:00 ` Jan Hubicka
2024-01-17 14:25 ` Richard Biener
2024-01-17 15:53 ` Jan Hubicka
2024-01-18 10:33 ` Richard Biener [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10nqoq23-98s9-p9n4-rnp9-01n5np9051q8@fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).