Re: problems with optimisation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 29/12/12 17:26, David Brown wrote:
> With -Os, the compiler will obey normal "inline" directives (at least,
> that is my experience when compiling C on the avr - I have not tried
> C++ much on it).  It won't do any automatic extra inlining, except for
> static functions that are only used once - which are always inlined as
> this saves space.  Again, I don't know how that plays with template
> functions or other C++ features.
>
> As far as I know, gcc uses weighting heuristics to decide whether to
> do something the rcall you mentioned above, compared to using the
> inlined code directly.  It is certainly not impossible that the
> weightings are not optimal here.
>
> There is currently very little use of C++ with avr-gcc.  The avr port
> maintainers and the avrlibc developers have little experience with
> C++, and feel they have enough to do with just the C support.  But
> there are a few people on the avr-gcc mailing list that work with C++,
> and it is certainly worth posting there too - they may be able to give
> suggestions.
>
> <https://lists.nongnu.org/mailman/listinfo/avr-gcc-list>
>
> mvh.,
>
> David

I got good results (code apparently better) using -O3 in avr instead of
-Os. Just the skipped instructions in the prologue and epiloques may be
worth it. It may that since on avr you have one cycle per instruction
(except branches), when optimizing for speed, you indirectly also
optimize the number of instructions. However, I was using C, not C++, so
the different way of coding could lead to worse optimizations.
I recommend giving gcc as much information as possible, and watch the
generated code. I got gcc to perform a few tricky optimizations, and in
one case, I manually unrolled a loop for him (otherwise, it didn't
notice it could be optimized). If you see a very bad instance of code
generation, open a bug. :)
What difference do you have from -Os to -O3 ?



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux