On Tue, May 18, 2010 at 9:43 AM, Richard Warburton <richard.warburton@gmail.com> wrote:
Is there any way to encourage it to do so, for example compilation flags?

No. It would be difficult for the compiler to see when CSE is or is not safe to apply, and so it doesn't have any code to perform full CSE at all.
 
Or is it generally best to hand apply these kind of optimisations.

Since the compiler won't do it for you, the answer is yes :-)