From: Krzysztof <kj@limes.com.pl>
To: linux-c-programming@vger.kernel.org
Subject: Is it helpful for a compiler to optimize?
Date: Sun, 03 Jun 2012 08:38:00 +0200 [thread overview]
Message-ID: <jqf0o8$cj4$1@dough.gmane.org> (raw)
Let's have a below code:
struct st
{
int iv;
/*...*/
};
void afun(struct st *stp)
{
stp->iv++;
printf("%d\n",stp->iv);
}
Is it helpful for a compiler to do better optimization if I write the
function as this?
void afun(struct st *stp)
{
int liv=stp->iv++;
printf("%d\n",liv);
}
In other words, is it better from optimization point of view to do
assignments structure members values to local variables then do what you
need to and then assign them back to member variables?
--
Regards
Krzysztof J.
next reply other threads:[~2012-06-03 6:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-03 6:38 Krzysztof [this message]
2012-06-03 6:59 ` Is it helpful for a compiler to optimize? Krzysztof
2012-06-04 14:09 ` Srinivasa T N
2012-06-03 8:03 ` Jesse Ruffin
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='jqf0o8$cj4$1@dough.gmane.org' \
--to=kj@limes.com.pl \
--cc=linux-c-programming@vger.kernel.org \
/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 NNTP newsgroup(s).