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: dewar at gnat dot com (Robert Dewar)
- To: dewar at adacore dot com, pinskia at physics dot uc dot edu
- Cc: autoconf-patches at gnu dot org, bernds_cb1 at t-online dot de, bug-gnulib at gnu dot org, ebb9 at byu dot net, eggert at cs dot ucla dot edu, gcc at gcc dot gnu dot org, gdr at integrable-solutions dot net, kenner at vlsi1 dot ultra dot nyu dot edu, richard dot guenther at gmail dot com
- Date: Sat, 30 Dec 2006 20:00:48 -0500 (EST)
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
Andrew Pinski wrote:
It does buy you something for code like:
if (a - 10 < 20)
Well that particular example is far fetched in code that people
expect to run efficiently, but with a bit of effort you could
come up with a more realistic example.
Compilers are always full of such optimizations which are simple to do
and get put in without any sound basis for determining that they actually
help.
Now if they don't change semantics, then unhelpful optimizations (by this
I mean optimizations which don't in practice help real applications), are
only slightly damaging (they damage maintainability and reliability by
creating additional unnecessary special cases).
But if they are NOT semantically neutral in terms of expected usage, then
the burden should be much higher.
In my view, this comparison optimization should not have been put in
without justification given that it clearly does affect the semantics
of real code. Indeed if you really see code like
if (a - 10 < 20)
in place of
if (a < 30)
a very likely explanation is that you are deliberately doing something
strange with wrap around, and should leave it alone.
You say "I don't want to see this optimization removed", why not?
The answer should hopefully be something like
because test # 5 in benchmark suite xxx takes a 3% hit
or even better
awk processing expressions like bla bla takes an n% hit
However, I suspect the real answer is
"it's a neat optimization, I did it, and it can only help, so why not
leave it in"
And that's to me not good enough for optimziations that break existing
programs.
Note that if (a - 10 < 20)
in the presence of wrap around semantics means something like
if (a < 30 && a > minint + 9) ...
and perhaps that was exactly what was meant!