|
Boost Users : |
From: Johan Oudinet (johan.oudinet_at_[hidden])
Date: 2007-10-11 03:51:31
On 10/11/07, Erik <sigra_at_[hidden]> wrote:
> I have not made any timings, but looked at the number of instructions in
> the assembly. I assume this corresponds to code size. The good news is
> that with g++-4.2.0 -O3 there appears to be no abstraction penalty at
> all. BOOST_FOREACH is equivalent to the handcoded loop and my macro.
> They both have 21 instructions (which appear to be equivalent; some of
> them are reordered and some have their parameters swapped). But with -Os
> it is possible to get only 20 instructions with handcoded/my macro,
> while BOOST_FOREACH actually gives 57 instructions (-Os giving more
> instructions than -O3 for ANY code looks like a compiler bug to me). And
$ man gcc
-----8<-----
-Os Optimize for size. -Os enables all -O2 optimizations that do not
typically increase code size. It also performs further optimiza$B!>(B
tions designed to reduce code size.
----8<------
The result of combining optimization flags for a specific program is
unknown. The -Ox options of gcc use some combinations that work well
most of the time, but not all the time ! Unfortunately, choosing the
best combination of optimization flags is an unsolved problem and
depends of both the code and the data set.
So, if the optimizations don't work for your code, it's not inevitably
a bug of your compiler.
P.S.: If you have to select a good set of optimization flags, there
are softwares that aim is to automatize this selection...
Regards,
-- Johan
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net