From: Martin Buchholz <martin@xemacs.org>
To: Joe Buck <jbuck@synopsys.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Optimization advice for maintainers: go for low-hanging fruit
Date: Tue, 24 Dec 2002 06:34:00 -0000 [thread overview]
Message-ID: <15880.3308.59512.557503@wobble.local> (raw)
In-Reply-To: <20021223155357.B3289@synopsys.com>
>>>>> "J" == Joe Buck <jbuck@synopsys.com> writes:
>> c++/8936: Declaration of never defined member function changes generated code
>> optimization/8952: failure to optimize away trivial C++ object creation
>> optimization/8967: Making class data members `const' pessimizes code
>> optimization/9016: Failure to consistently constant fold "constant" C++ objects
J> Some of the oddities you point out seem to come from the fact that
J> subsequent passes of the compiler seem to succeed in doing optimizations
J> only sometimes, and that conditions for these passes to work (e.g. dead
J> store elimination) are rather brittle. It would certainly be interesting
J> to determine just what is different in cases 8936 and 8967.
Some of those bugs are regressions from previous g++ versions, showing
that g++ can certainly do a better job without massive infrastructure work.
For example, Wolfgang's experiments with PR8967 shows things getting
worse with successive g++ versions.
J> Many of us believe that tree-based optimizations can be the way out for
J> many of these cases: do optimizations that are easy on trees well before
J> conversion to RTL. Work is in progress to provide an infrastructure
J> that will allow this to be done.
Another argument for why I expect g++ to do better today:
A clever C++ compiler can figure out that an expression like
Complex(1,2)
is a compile-time constant and optimize appropriately at
compile-time. But semantically, this is equivalent to
double real = 1.0;
double imag = 2.0;
which a C compiler can do constant-folding on, probably just as well
as C++.
From a very high level, I regard a C++ front end's job as translating
C++ into something semantically very close to C code. Although there
may be additional opportunities for optimization by understanding and
optimizing C++ constructs, the meat of the optimizations should be
occuring at the "C level".
For example, if a C++ compiler sees
Complex(1,a) + Complex(2,b)
it shouldn't say "no constants here, so no constant-folding here."
Instead, there should be constant-folding on the real parts of those
Complex variables, just as if it had been written in C using variables
of type "double".
So I'm still a believer in the value of low-level optimizations,
ones that don't know about higher-level things like classes.
Martin (not a compiler writer)
prev parent reply other threads:[~2002-12-24 7:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-20 3:44 Martin Buchholz
2002-12-20 8:17 ` Jan Hubicka
2002-12-20 11:01 ` Dan Nicolaescu
2002-12-23 18:06 ` Joe Buck
2002-12-24 6:34 ` Martin Buchholz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15880.3308.59512.557503@wobble.local \
--to=martin@xemacs.org \
--cc=gcc@gcc.gnu.org \
--cc=jbuck@synopsys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).