Is it helpful for a compiler to optimize?

Krzysztof <[email protected]> Sun, 03 Jun 2012 08:38:00 +0200
Newsgroups gmane.linux.c-programming
Message-ID <[email protected]>
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?

-- 
Regards
Krzysztof J.


--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html