This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC -On optimization passes: flag and doc issues


Kenneth Hoste <kenneth.hoste@elis.ugent.be> writes:

> * When using -falign-loops or -fno-align-loops the corresponding
> internal variable 'align-loops' should be set to 0 (= use default
> setting) or 1 (= no aligning) resp. When parsing the various flags, a
> variable 'value' is used to set (value=1) or unset (value=0) the
> corresponding flag. Unfortunately, these values should be reversed
> for the -falign-X flags, which isn't done, and thus using -falign-
> loops causes no aligning, while -fno-align-loops causes aligning with
> the default setting for the arch you're compiling for. Same problem
> for -falign-jumps, -falign-labels and -falign-functions.

Ouch.  Thanks for noticing.

> * On x86, -fschedule-insns is disabled, but -fschedule-insns2 (or the
> corresponding internal flag flag_schedule_insns_after_reload) is
> still being used... The reason for disabling fschedule-insns is
> increased register pressure (and x86 has few registers already). I'm
> not sure if this a bug, but why disable -fschedule-insns and leave -
> fschedule-insns2 active? Because , according to the docs, fschedule-
> insns2 = fschedule-insns + an additional pass. Any comments on this
> are welcome...

As Steven mentioned, this is expected.  The docs are, perhaps,
slightly misleading.  -fschedule-insns2 does not imply
-fschedule-insns.  The two options are independent.  -fschedule-insns2
runs after register allocation and therefore does not increase
register pressure.

> I've file a bug report for the first issue (http://gcc.gnu.org/
> bugzilla/show_bug.cgi?id=31586), but since this is easy to fix, I'd
> like to fix it myself. The only thing holding me back is that I'm new
> at this: I've never contributed to an open source project before, and
> I'm only vaguely familiar with CVS and the likes. Is there a newbie-
> guide to contributing to GCC? How can I make sure this fix is done
> for 4.1, 4.2 _and_ 4.3?

Source code access is described at http://gcc.gnu.org/svn.html.  There
is some general, not very well organized, information on the gcc wiki
at http://gcc.gnu.org/wiki/.  You should first write the patch for
mainline (4.3).  When that is accepted, you can backport the patch to
the 4.1 and 4.2 branches.

> Also, while trying to identify the flags enabled in the various -On
> flags, I've run into incomplete or even wrong documentation regarding
> the optimization passes. Some examples:
> 
> - the -fipa-X flags are not mentioned in the 4.1.2 documentation

Looks like a bug.

> - funit-at-a-time is still being reported as enabled in -O2 and
> above, while it is already active in -O1 (this seems to fixed in the
> 4.3.0 docs though)

This would be a bug but it looks OK to me in 4.1.

> - the documentation for fmove-loop-invariants and ftree-loop-optimize
> mentions they are enabled at -O1 when they are not

Actually I think they are enabled at -O1.  This is done in a slightly
tricky way: they default to being on, but they have no effect unless
the other loop optimization passes are run.  I think it would be
appropriate to clean this up to make the code more obvious.

> - finline-functions is enabled at -Os, but isn't listed so

Yes, this should be documented better.  The general -finline-functions
is not enabled at -Os.  Only inlining of small functions is enabled.
This is done by setting parameters.

> - Some flags are enabled by other flags (for example, fschedule-insns
> enables fsched-interblock and fsched-spec according to the docs). I
> was unable to find where in the source code this is done... And
> because I want to incorporate as much active On-flags as possible,
> I'd like to track down for which flags this is really true, and for
> which the docs are out-of-date.

-fsched-interblock and -fsched-spec default to 1 in common.opt.  But
they have no effect unless you enable a scheduling pass.

> - When new optimization passes are completed, how is decided where
> they go to (-O1, -O2, -O3, -Os, none)? For example, why did funit-at-
> a-time switch from -O2 to -O1 a while ago? And, as I noticed from the
> 4.3.0 docs, why is fsplit-wide-types enabled at -O1, and not -O2? Is
> there some testing done, or is it just people saying "I think X
> belongs there"?

Where to put optimizations is a trade-off between the amount of time
they take and the amount of good they do.  The testing which is done
is compilation time testing.

-funit-at-a-time was moved from -O2 to -O1 because we are likely to
make it the default in all cases, including -O0.  Making
-funit-at-a-time the default will simplify several cases in the
compiler.  It is already the default in all cases for C++.

-fsplit-wide-types is at -O1 because it is normally cheap in terms of
compilation time.  It doesn't do anything if there are no "long long"
local variables in the function (or, more generally, no variables
whose type is such that they are twice the width of a general
register).

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]