public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* a question about code optimization
@ 2007-12-22  5:41 龙海涛
  2007-12-22 10:20 ` Christoph Bartoschek
  0 siblings, 1 reply; 8+ messages in thread
From: 龙海涛 @ 2007-12-22  5:41 UTC (permalink / raw)
  To: gcc-help

---------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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-01-09 14:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <C3A0E1D1.29B03%eljay@adobe.com>
2008-01-04 14:38 ` a question about code optimization 龙海涛
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
2007-12-22  5:41 龙海涛
2007-12-22 10:20 ` Christoph Bartoschek
2007-12-25  3:00   ` 龙海涛

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).