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: Robert Dewar <dewar at adacore dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Richard Guenther <richard dot guenther at gmail dot com>, Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>, ebb9 at byu dot net, autoconf-patches at gnu dot org, bernds_cb1 at t-online dot de, bug-gnulib at gnu dot org, eggert at cs dot ucla dot edu, gcc at gcc dot gnu dot org
- Date: Sat, 30 Dec 2006 20:07:09 -0500
- Subject: Re: changing "configure" to default to "gcc -g -O2 -fwrapv ..."
- References: <200612310042.kBV0g5pt027400@localhost.localdomain>
(first, sorry for breaking the thread, pilot error on my part)
Here is the message again properly threaded. The other broken
thread by dewar's evil twin can be discarded.
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. I don't know
if it really helps, but I can concoct an example where it would help,
so why not leave it in, every little bit helps when it comes to high
performance.
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!