public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ángel González" <keisial@gmail.com>
To: David Brown <david@westcontrol.com>
Cc: Kicer <kicer86@gmail.com>, Andrew Haley <aph@redhat.com>,
	 gcc-help@gcc.gnu.org
Subject: Re: problems with optimisation
Date: Sat, 29 Dec 2012 22:28:00 -0000	[thread overview]
Message-ID: <50DF6E0F.5090707@gmail.com> (raw)
In-Reply-To: <50DF19A5.2020909@westcontrol.com>

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 ?

  reply	other threads:[~2012-12-29 22:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-28 10:25 Kicer
2012-12-28 15:19 ` Andrew Haley
2012-12-28 16:34   ` David Brown
2012-12-28 17:14     ` Kicer
2012-12-29 16:26       ` David Brown
2012-12-29 22:28         ` Ángel González [this message]
2012-12-30  9:51           ` Kicer
2012-12-30 11:25           ` David Brown
2012-12-30  9:47         ` Kicer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50DF6E0F.5090707@gmail.com \
    --to=keisial@gmail.com \
    --cc=aph@redhat.com \
    --cc=david@westcontrol.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=kicer86@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).