If we have a following block,
{
int i = 20;
int j = 40;
...
int k = i * j;
printf("k = %d, i = %d, j = %d\n", k, i, j);
}
Then the compiler would optimize this block in a way that i, j, and k variables never exist, since the block only uses values of them. Also, these values are within the scope of the block too. Thus, the compiler simply replaces the variables with constants. However, if the block ever uses reference or addresses, then it is illegal for compiler to optimize them. In this case, the compiler wouldn't optimize those variables away.
No comments:
Post a Comment