Conmpile speed vs Runtime speed
Robert Dewar
dewar@gnat.com
Sat Apr 3 22:25:00 GMT 2004
> As a user of GCC (and other compilers) and as someone that has been
> following GCC development for a while, I would like to suggest this:
> The higher the optomization flags, the more GCC should favor runtime speed
> over compile speed.
You are stating the accepted obvious!
This of COURSE is the policy that governs here.
> Basicly, at -O0 (usually used for debugging), compile speed should be
> favoured over runtime speed (since you probobly dont care a huge deal about
> the runtime speed since you didnt optomize the program but you do care
> about the compile speed since you are likely to need to recompile all the time)
You can't make this absolute. Failure to optimize at all means you generate
more code, and that can slow things down in the development cycle. It is
not pleasant to work with 200 megabyte executable images :-)
> And at -O2, favor runtime speed over compile speed. Typically you build at
> -O2 when you are building an optomized build (to ship, for tests or
> whatever else) and it stands to reason that you would want the fastest EXE
> possible.
Again this is not absolute, and you don't mean what you say. For instance,
the best possible job of register allocation (needed for "the fastest
EXE possible" is known to require an exponential amount of time. In
practice that means that generating optimal code in this one respect
can take huge amounts of time. IBM on some of its early compilers
had a switch -noNP or something like that, to tell the compiler not
to attempt an exponential search if it could not immediately find
an optimal solution. Without this switch, they had examples of 100
line programs taking many hours to compile.
So while you state a reasonable general principle, it cannot be taken
to extremes.
The idea of recompiling a program at -O2 to ship it, without entirely
repeating the entire testing procedure, is a bit unrealistic :-)
More information about the Gcc
mailing list