This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Robert Dewar" <dewar at adacore dot com>
- Cc: "Geert Bosch" <bosch at adacore dot com>, "Daniel Berlin" <dberlin at dberlin dot org>, "Paul Eggert" <eggert at cs dot ucla dot edu>, autoconf-patches at gnu dot org, bug-gnulib at gnu dot org, gcc at gcc dot gnu dot org
- Date: Tue, 2 Jan 2007 16:01:06 +0100
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- References: <200612300047.kBU0lFwk014817@localhost.localdomain> <8764bssikm.fsf@penguin.cs.ucla.edu> <571f6b510612310047r3b7ef9acl4a0ab082e88e17a3@mail.gmail.com> <87bqlkmm3r.fsf@penguin.cs.ucla.edu> <4aca3dc20612310641n78e8898euf1c003444e2303eb@mail.gmail.com> <84fc9c000612310645h67066c70vf9eb11af74b639a7@mail.gmail.com> <4aca3dc20612311613r2992db50o851c7d73603b42ef@mail.gmail.com> <22C62FE7-259E-43F7-9DB5-5F3A9CF574E2@adacore.com> <84fc9c000701020204v5e5ad239uec526652ff18eedc@mail.gmail.com> <459A64EF.1090801@adacore.com>
On 1/2/07, Robert Dewar <dewar@adacore.com> wrote:
Richard Guenther wrote:
> On 1/1/07, Geert Bosch <bosch@adacore.com> wrote:
specfp.
>
> I would support the proposal to enable -fwrapv for -O[01], but
> not for -O2 as that is supposed to be "optimize for speed" and
> as -O3 is not widely used to optimize for speed (in fact it may
> make code slower). I'm undecided for -Os but care less about it.
I think it is a bad idea for the optimization levels to deal with
anything other than optimization. -fwrapv is not about optimization,
it is about changing the language semantics.
So this proposal would be tantamount to implementing a different
language at -O1 and -O2, and having -O2 change the formal
semantic interpretation of the program. That seems a very
bad idea to me.
We do that with -fstrict-aliasing, which also changes language semantics.
-fstrict-aliasing is disabled for -O0 and -O1 and enabled for -O[23s].
It is one thing to have different optimization levels do different
amounts of optimization that in practice may have more or less
effect on non-standard programs. It is quite another to guarantee
at a formal semantic level wrapping at -O1 and not -O2.
If we decide to avoid some optimizations at -O1 in this area,
that's fine, but it should not be done by enabling -fwrapv as
one of the (presumably documented) flags included in -O1.
Instead I would just do this silently without the guarantee.
And I continue to favor the compromise approach where loop
optimization can use undefinedness of overflow in dealing
with loop invariants, but we don't by default take advantage
of undefinedess elsewhere.
I fear this is not as easy as it sounds, as loop optimizers (and basically
every optimizer) calls back into fold to do simplifications to for example
predicates it tries to prove. Unless you change this by either duplicating
these parts of fold or putting logic into fold that checks
current_pass == loop_optimizer
you will not catch those cases.
Also all of VRP, loop optimizers and fold do comparison simplification which
benefits from signed overflow undefinedness the most (note that this is another
area of cleanup I'm likely to touch in not too distant future).
Then we have two switches:
-fstandard
which allows all optimizations (name can be changed, I
don't care about the name)
-fwrapv
which changes the semantics to require wrapping in
all cases (including loops)
How do these switches implement your proposal? "All optimiations" sounds
like the -fno-wrapv case we have now.
Richard.