[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."

From: Richard Guenther
Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Date: Tue, 2 Jan 2007 16:01:06 +0100

On 1/2/07, Robert Dewar <address@hidden> wrote:
Richard Guenther wrote:
> On 1/1/07, Geert Bosch <address@hidden> wrote:
> 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:


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)

How do these switches implement your proposal?  "All optimiations" sounds
like the -fno-wrapv case we have now.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]