This is the mail archive of the
mailing list for the GCC project.
Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- From: Robert Dewar <dewar at adacore dot com>
- To: Richard Guenther <richard dot guenther at gmail 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, 02 Jan 2007 08:58:07 -0500
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- References: <200612300047.kBU0lFwk014817@localhost.localdomain> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <22C62FE7-259E-43F7-9DB5-5F3A9CF574E2@adacore.com> <email@example.com>
Richard Guenther wrote:
On 1/1/07, Geert Bosch <firstname.lastname@example.org> wrote:
I would support the proposal to enable -fwrapv for -O, 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.
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.
Then we have two switches:
which allows all optimizations (name can be changed, I
don't care about the name)
which changes the semantics to require wrapping in
all cases (including loops)