public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: 龙海涛 <longhaitao@otsc.com.cn>
To: gcc-help@gcc.gnu.org
Subject: a question about code optimization
Date: Sat, 22 Dec 2007 05:41:00 -0000	[thread overview]
Message-ID: <476CA397.2010505@otsc.com.cn> (raw)

---------code-----------
vector<int> a;
/*do somthing*/
for(int i = 0; i<a.size(); i++) {
	/* do something*/
}
--------code end--------

my question is:
is it possible that the compiler will transform the code to this:

int __tmp = a.size();
for(int i = 0; i < __tmp; i++) {
	/*do something*/
}

i think it is impoossible,because in size() function, the programmer
can change some global variables, so the compiler could not do that.

if gcc can, could you tell me how?

i am sorry in advance because i am not familiar with the code optimization.
so i do not know how to search the gcc manual and gcc internal manual to find
answer.could anyone tell me how to find this in the manual拢驴or at least give
some keywords?

             reply	other threads:[~2007-12-22  5:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-22  5:41 龙海涛 [this message]
2007-12-22 10:20 ` Christoph Bartoschek
2007-12-25  3:00   ` 龙海涛
     [not found] <C3A0E1D1.29B03%eljay@adobe.com>
2008-01-04 14:38 ` 龙海涛
2008-01-05 14:25   ` John Love-Jensen
2008-01-09 17:06     ` 龙海涛
2008-01-09 23:03       ` 龙海涛
2008-01-10 19:51       ` John Love-Jensen

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=476CA397.2010505@otsc.com.cn \
    --to=longhaitao@otsc.com.cn \
    --cc=gcc-help@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).