This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
a question about code optimization
- From: 龙海涛 <longhaitao at otsc dot com dot cn>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 22 Dec 2007 13:41:43 +0800
- Subject: a question about code optimization
---------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?