From: | bob.morgan@digital.com (Bob Morgan) |
Newsgroups: | comp.compilers |
Date: | 3 Aug 1998 17:59:42 -0400 |
Organization: | Digital Equipment Corporation |
References: | 98-08-011 |
Keywords: | C, C++, performance |
I would disagree with some of your reasoning. Using your numbering:
1) One of the fallacies of high level languages, is that high level
optimizations can be applied without low-level optimizations. My
experience with higher-level languages is that the high-level
optimizations (vectorization for example) are of little use without
the low-level optimizations to clean up the code. Thus a C++ compiler
needs all of the optimizations that a C compiler together with the OO
optimizations specific to C++.
2) Agreed, a C++ compiler will be more expensive to implement in
money, time and resources. If one is implementing an optimizing C++
compiler one must spend the resources, otherwise it is probably not
worth doing.
3) The OO-optimizations are irrelevant to C; however, the point I made
above is that the C optimizations are highly relevant to C++ so they
have to be there.
You can make the argument that a C++ compiler will be more complex,
that it will take longer to get it to production quality, and it will
take more resources. But the resources must be spent or the OO
optimizations will not pay off.
A side comment: have you ever wondered when the technology was
available to build an optimizing compiler as effective as the
compilers available today? I claim that all the technology needed to
build a parallelizing, vectorizing, compiler for RISC computers was
available in 1972. (well maybe not trace scheduling). At that point
instruction scheduling was known, parallelization was known (ILLIAC
IV), optimization was known, register allocation was known, etc.
Then, what have we been doing for the last 26 years? We have been
building simpler models and algorithms to make the compilers smaller
and more bug free.
This point feeds directly into your question. Today an optimizing C++
compiler will be bigger than a C compiler and harder to develop;
however, the role of compiler research is to build simpler algorithms
with the same effectiveness so that the C++ compiler will eventually
be smaller and use simpler algorithms.
Bob Morgan
P.S.: I can imagine that a C++ compiler might eventually generate
better code than a C compiler for some program where the C program
mimics the algorithms of the C++ program. Why? If the program can be
analyzed at a higher level, more information may be gained providing
an insight (probably about aliasing of pointers) that will allow
better code. For example, the compiler may be able to identify a data
structure as a list and allow parallel execution of a loop.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.