Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default flags enabled by GCC at -O3 by default appear to be out of sync with the GCC documentation #3

Closed
InBetweenNames opened this issue Sep 12, 2017 · 10 comments

Comments

@InBetweenNames
Copy link
Owner

InBetweenNames commented Sep 12, 2017

Hi everyone,

I was working on refining make.conf today and I noticed a bit of an oddity. On GCC's docs, they give a list of all optimizations enabled by default at O3:

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Curiously, they list -ftree-loop-distribution as being enabled by default by O3, but in my own GCC it remains disabled:

>gcc --version
gcc (Gentoo 7.2.0 p1.1) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>gcc -c -Q -O3 --help=optimizers | grep distribut                                                                                                                                                                                                                       Tue 12 Sep 2017 09:37:44 AM EDT
  -ftree-loop-distribute-patterns       [enabled]
  -ftree-loop-distribution              [disabled]

I was wondering if anyone could check if this is the case on their systems too? Please include your GCC version in your response. If I can get at least one person to reproduce this bug I'll make a bug report in GCC.

@darkbasic
Copy link
Contributor

darkbasic commented Sep 12, 2017

ArchLinux:

$ gcc --version
gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -c -Q -O3 --help=optimizers | grep distribut
  -ftree-loop-distribute-patterns       [enabled]
  -ftree-loop-distribution              [disabled]

P.S.
You removed your GCC version from the output.

@InBetweenNames
Copy link
Owner Author

Whoops--copied in some extraneous spaces from my terminal that hid it. Thanks!

@InBetweenNames
Copy link
Owner Author

That's interesting. I'll check GCC HEAD to see if it's enabled in there.

@mgomersbach
Copy link
Contributor

Same for 6.4.0:

$ gcc --version 
gcc (Gentoo 6.4.0 p1.0) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



$ gcc -c -Q -O3 --help=optimizers | grep distribut
  -ftree-loop-distribute-patterns 	[enabled]
  -ftree-loop-distribution    		[disabled]

The documentation changed between 4.9.4 and 5.1.0

@preney
Copy link
Contributor

preney commented Sep 12, 2017

If the documentation changed between 4.9.4 and 5.1.0, then that doesn't explain why my GCC output for v4.9.4 is the same as v5.4.0, v6.4.0, and v7.2.0, e.g.,

    $ gcc-4.9.4 --version
    gcc-4.9.4 (Gentoo 4.9.4 p1.0, pie-0.6.4) 4.9.4
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    $ gcc-4.9.4 -c -Q -O3 --help=optimizers | grep distribut
         -ftree-loop-distribute-patterns       [enabled]
         -ftree-loop-distribution              [disabled]

i.e., the -c -Q -O3 --help=optimizers outputs are all identical --so the GCC documentation differs from the settings (unless this is due to a Gentoo patch on GCC --I didn't check).

@preney
Copy link
Contributor

preney commented Sep 12, 2017

It is entirely possible that the graphite or some other Gentoo USE flag changes this setting. Checking with GCC pristine sources is the only definitive way to know for sure if the docs are out-of-sync.

@InBetweenNames
Copy link
Owner Author

Per the GCC 7.2.0 sources, file gcc/opts.c, starting from line 528:

    { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 },
    /* Inlining of functions reducing size is a good idea with -Os
       regardless of them being declared inline.  */
    { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 },
    { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_finline_functions_called_once, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fsplit_loops, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_ftree_loop_vectorize, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_ftree_slp_vectorize, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_DYNAMIC },
    { OPT_LEVELS_3_PLUS, OPT_fipa_cp_clone, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_ftree_partial_pre, NULL, 1 },
    { OPT_LEVELS_3_PLUS, OPT_fpeel_loops, NULL, 1 },

Note in that list, ftree_loop_distribution is not present. I think either the docs should be amended or the O3 options should be.

@InBetweenNames
Copy link
Owner Author

Just built GCC 7.2.0 from scratch just to be sure there weren't any build time modifications that would change the state of the flag.

host-x86_64-pc-linux-gnu/gcc/cc1 -c -Q -O3 --help=optimizers | grep distribu                                                                                                                                                                                                   Tue 12 Sep 2017 05:05:16 PM EDT
cc1: error: command line option ‘-c’ is valid for the driver but not for C
cc1: error: command line option ‘-Q’ is valid for the driver but not for C
  -ftree-loop-distribute-patterns       [enabled]
  -ftree-loop-distribution              [disabled]

Unless someone has an objection, I'm going to go ahead and file a bug report upstream

@InBetweenNames
Copy link
Owner Author

Bug report is here, for interested parties: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82197

@InBetweenNames
Copy link
Owner Author

Turns out this documentation is actually for GCC trunk. TIL! The behaviour is correct for 6.4.0 and 7.2.0. I'll make a note to revise the flags for the next GCC release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants