diff mbox series

doc: Document -O1 as the preferred level for large machine-generated code

Message ID 5eef1b19afac0f6608f5a44e9560ca703752d689.1721743570.git.sam@gentoo.org
State New
Headers show
Series doc: Document -O1 as the preferred level for large machine-generated code | expand

Commit Message

Sam James July 23, 2024, 2:06 p.m. UTC
At -O1, the intention is that we compile things in a "reasonable" amount
of time (ditto memory use). In particular, we try to especially avoid
optimizations which scale poorly on pathological cases, as is the case
for large machine-generated code.

Recommend -O1 for large machine-generated code, as has been informally
done on bugs for a while now.

This applies (broadly speaking) for both large machine-generated functions
but also to a lesser extent repetitive small-but-still-not-tiny functions
from a generator program.

gcc/ChangeLog:
	PR middle-end/114855
	* doc/invoke.texi (Optimize options): Mention machine-generated
	code for -O1.
---
richi, does this accurately reflect the discussion we had on IRC a little
while ago?

Please push if OK, thanks.

 gcc/doc/invoke.texi | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Sam James July 23, 2024, 3:19 p.m. UTC | #1
Sam James <sam@gentoo.org> writes:

(oops, forgot to CC docs maintainers. Done now.)

> At -O1, the intention is that we compile things in a "reasonable" amount
> of time (ditto memory use). In particular, we try to especially avoid
> optimizations which scale poorly on pathological cases, as is the case
> for large machine-generated code.
>
> Recommend -O1 for large machine-generated code, as has been informally
> done on bugs for a while now.
>
> This applies (broadly speaking) for both large machine-generated functions
> but also to a lesser extent repetitive small-but-still-not-tiny functions
> from a generator program.
>
> gcc/ChangeLog:
> 	PR middle-end/114855
> 	* doc/invoke.texi (Optimize options): Mention machine-generated
> 	code for -O1.
> ---
> richi, does this accurately reflect the discussion we had on IRC a little
> while ago?
>
> Please push if OK, thanks.
>
>  gcc/doc/invoke.texi | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index e0a641213ae4..9fb0925ed292 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -12560,6 +12560,11 @@ With @option{-O}, the compiler tries to reduce code size and execution
>  time, without performing any optimizations that take a great deal of
>  compilation time.
>  
> +@option{-O} is the recommended optimization level for large machine-generated
> +code as a sensible balance between time taken to compile and memory use:
> +higher optimization levels perform optimizations with greater algorithmic
> +complexity than at @option{-O}.
> +
>  @c Note that in addition to the default_options_table list in opts.cc,
>  @c several optimization flags default to true but control optimization
>  @c passes that are explicitly disabled at -O0.
Eric Gallager July 25, 2024, 8:37 a.m. UTC | #2
On Tue, Jul 23, 2024 at 10:07 AM Sam James <sam@gentoo.org> wrote:
>
> At -O1, the intention is that we compile things in a "reasonable" amount
> of time (ditto memory use). In particular, we try to especially avoid
> optimizations which scale poorly on pathological cases, as is the case
> for large machine-generated code.
>
> Recommend -O1 for large machine-generated code, as has been informally
> done on bugs for a while now.
>
> This applies (broadly speaking) for both large machine-generated functions
> but also to a lesser extent repetitive small-but-still-not-tiny functions
> from a generator program.
>
> gcc/ChangeLog:
>         PR middle-end/114855
>         * doc/invoke.texi (Optimize options): Mention machine-generated
>         code for -O1.
> ---
> richi, does this accurately reflect the discussion we had on IRC a little
> while ago?
>
> Please push if OK, thanks.
>
>  gcc/doc/invoke.texi | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index e0a641213ae4..9fb0925ed292 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -12560,6 +12560,11 @@ With @option{-O}, the compiler tries to reduce code size and execution
>  time, without performing any optimizations that take a great deal of
>  compilation time.
>
> +@option{-O} is the recommended optimization level for large machine-generated
> +code as a sensible balance between time taken to compile and memory use:
> +higher optimization levels perform optimizations with greater algorithmic
> +complexity than at @option{-O}.
> +

Personally, I get confused when "-O1" is written as just "-O"...

>  @c Note that in addition to the default_options_table list in opts.cc,
>  @c several optimization flags default to true but control optimization
>  @c passes that are explicitly disabled at -O0.
>
> --
> 2.45.2
>
Sam James July 25, 2024, 11:28 a.m. UTC | #3
Eric Gallager <egall@gwmail.gwu.edu> writes:

> On Tue, Jul 23, 2024 at 10:07 AM Sam James <sam@gentoo.org> wrote:
>>
>> At -O1, the intention is that we compile things in a "reasonable" amount
>> of time (ditto memory use). In particular, we try to especially avoid
>> optimizations which scale poorly on pathological cases, as is the case
>> for large machine-generated code.
>>
>> Recommend -O1 for large machine-generated code, as has been informally
>> done on bugs for a while now.
>>
>> This applies (broadly speaking) for both large machine-generated functions
>> but also to a lesser extent repetitive small-but-still-not-tiny functions
>> from a generator program.
>>
>> gcc/ChangeLog:
>>         PR middle-end/114855
>>         * doc/invoke.texi (Optimize options): Mention machine-generated
>>         code for -O1.
>> ---
>> richi, does this accurately reflect the discussion we had on IRC a little
>> while ago?
>>
>> Please push if OK, thanks.
>>
>>  gcc/doc/invoke.texi | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index e0a641213ae4..9fb0925ed292 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -12560,6 +12560,11 @@ With @option{-O}, the compiler tries to reduce code size and execution
>>  time, without performing any optimizations that take a great deal of
>>  compilation time.
>>
>> +@option{-O} is the recommended optimization level for large machine-generated
>> +code as a sensible balance between time taken to compile and memory use:
>> +higher optimization levels perform optimizations with greater algorithmic
>> +complexity than at @option{-O}.
>> +
>
> Personally, I get confused when "-O1" is written as just "-O"...

I, too, prefer -O1, but I was trying to be good and stick to
convention. But then I did -O1 in the commit message.

If people are fine with it, I'd prefer to do -O1.

thanks,
sam
Richard Biener July 25, 2024, 12:21 p.m. UTC | #4
On Tue, Jul 23, 2024 at 4:07 PM Sam James <sam@gentoo.org> wrote:
>
> At -O1, the intention is that we compile things in a "reasonable" amount
> of time (ditto memory use). In particular, we try to especially avoid
> optimizations which scale poorly on pathological cases, as is the case
> for large machine-generated code.
>
> Recommend -O1 for large machine-generated code, as has been informally
> done on bugs for a while now.
>
> This applies (broadly speaking) for both large machine-generated functions
> but also to a lesser extent repetitive small-but-still-not-tiny functions
> from a generator program.
>
> gcc/ChangeLog:
>         PR middle-end/114855
>         * doc/invoke.texi (Optimize options): Mention machine-generated
>         code for -O1.
> ---
> richi, does this accurately reflect the discussion we had on IRC a little
> while ago?
>
> Please push if OK, thanks.

OK (I pushed it).

Richard.

>  gcc/doc/invoke.texi | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index e0a641213ae4..9fb0925ed292 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -12560,6 +12560,11 @@ With @option{-O}, the compiler tries to reduce code size and execution
>  time, without performing any optimizations that take a great deal of
>  compilation time.
>
> +@option{-O} is the recommended optimization level for large machine-generated
> +code as a sensible balance between time taken to compile and memory use:
> +higher optimization levels perform optimizations with greater algorithmic
> +complexity than at @option{-O}.
> +
>  @c Note that in addition to the default_options_table list in opts.cc,
>  @c several optimization flags default to true but control optimization
>  @c passes that are explicitly disabled at -O0.
>
> --
> 2.45.2
>
diff mbox series

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e0a641213ae4..9fb0925ed292 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12560,6 +12560,11 @@  With @option{-O}, the compiler tries to reduce code size and execution
 time, without performing any optimizations that take a great deal of
 compilation time.
 
+@option{-O} is the recommended optimization level for large machine-generated
+code as a sensible balance between time taken to compile and memory use:
+higher optimization levels perform optimizations with greater algorithmic
+complexity than at @option{-O}.
+
 @c Note that in addition to the default_options_table list in opts.cc,
 @c several optimization flags default to true but control optimization
 @c passes that are explicitly disabled at -O0.