1 |
On Wednesday 27 September 2006 11:11, "Hemmann, Volker Armin" |
2 |
<volker.armin.hemmann@××××××××××××.de> wrote about 'Re: [gentoo-amd64] |
3 |
First Impressions': |
4 |
> -O3 don't do it. O2 is much, much safer and not really slower. It will |
5 |
> prevent a lot of breakage. |
6 |
|
7 |
Bah! |
8 |
|
9 |
-O3 breaking just doesn't happen anymore. I'm been running it for years. |
10 |
In fact -O3 has never generated invalid code [1] on x86 or amd64 |
11 |
platforms. It did for a period of time on ppc, but I think that was like |
12 |
10 years ago. |
13 |
|
14 |
Also, some applications break with just -O2. I count 8 ebuilds that |
15 |
replace this cflag specifically, there could be others that filter it or |
16 |
filter/replace optimization options entirely. My methodology is available |
17 |
on request. |
18 |
|
19 |
Now, it is an open question whether -O3 is significantly faster than -O2 |
20 |
and depending on a number of factors it may actually be slower. -O3 will |
21 |
enlarge code to make execution paths shorter, but a cache miss is probably |
22 |
goes to blow away any advantage gained. Conversely, -Os will make |
23 |
execution paths longer to shrink code, and a cache hits may make up for |
24 |
the longer path. [2] |
25 |
|
26 |
So, which is best depends on the program and on the CPU used (not only |
27 |
instruction set, but also cache sizes). Therefore, making a sweeping |
28 |
recommendations is not recommended, but that doesn't stop anyone. My |
29 |
recommendation is -O3. :) |
30 |
|
31 |
Naturally, Gentoo wins over binary distros on this point, since you can use |
32 |
CFLAGS that are appropriate for your specific processor (including cflags |
33 |
which control the optimization tradeoff parameters) as well as tuning for |
34 |
the specific application. |
35 |
|
36 |
-- |
37 |
"If there's one thing we've established over the years, |
38 |
it's that the vast majority of our users don't have the slightest |
39 |
clue what's best for them in terms of package stability." |
40 |
-- Gentoo Developer Ciaran McCreesh |
41 |
|
42 |
[1] That doesn't mean there weren't programs that crashed when compiled |
43 |
under -O3, just that the deficiency was found to be with the program not |
44 |
the compiler. |
45 |
|
46 |
[2] But -Os may also break programs, and I've heard more problems on -Os |
47 |
than -O3 recently. -Os had also had times when it generates invalid code. |