Krzysztof
2012-06-03 06:38:00 UTC
Let's have a below code:
struct st
{
int iv;
/*...*/
};
void afun(struct st *stp)
{
stp->iv++;
printf("%d\n",stp->iv);
}
Is it helpful for a compiler to do better optimization if I write the
function as this?
void afun(struct st *stp)
{
int liv=stp->iv++;
printf("%d\n",liv);
}
In other words, is it better from optimization point of view to do
assignments structure members values to local variables then do what you
need to and then assign them back to member variables?
struct st
{
int iv;
/*...*/
};
void afun(struct st *stp)
{
stp->iv++;
printf("%d\n",stp->iv);
}
Is it helpful for a compiler to do better optimization if I write the
function as this?
void afun(struct st *stp)
{
int liv=stp->iv++;
printf("%d\n",liv);
}
In other words, is it better from optimization point of view to do
assignments structure members values to local variables then do what you
need to and then assign them back to member variables?
--
Regards
Krzysztof J.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Regards
Krzysztof J.
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html