I was doing an experiment to measure the execution time of ''for loop'' on microcotroller. This ''for loop'' contain some integer and pointer operation.
Case 1: when I set compiler optimizaion flag to '' none'' (no optimization) there is assembly code generated and I can measure the execution time.
Case 2: When I set the compiler optimization to ''speed'' (optimized for speed) then there is no assembly code generated for this loop. It seems like , Compiler throw out this ''for loop''
/* the basic concept behind this code is data manipulation in an array.Therefore I created an array then with the help of loops, tried to manipulate data*/
int abc[1000];
for(n=0; n<1000; n++)
{
abc[n]= 0xaa;
}
for(n=2; n<1000; n=n+2)
{
abc[n]= 0xbb;
}
for(n=5; n<1000; n=n+2)
{
for(i=(n+n); i<1000; i++)
{
abc[i]= i;
}
}
Could anyone explain why compiler throw out this loop , when I set compiler flag to speed.
If you don't use
abc
afterwards, it's possible that the optimizer recognized it (and all writes to it) as "dead" and removed it completely.