The last Xojo release brought us an optimization switch. We can now decide whether we want default, moderate or aggressive optimization. I just finished an article for Xojo Developer Magazine about some good optimization things happening. But there is still room for improvement.
For my article I have three nice cases to show you what is generated for default, moderate and aggressive, so you learn what the optimizer does. I see optimizations going on for loops, common subexpression and recalculating expressions.
But looking for optimization cases with math functions, the code generator could be better. As it does not use the standard functions for e.g. sqrt, but calls Xojo's runtime functions, the compiler can't optimize them away. (Feedback case 45298). And for multiple calls to object methods, the code generator could provide hints to compiler that self is not going to change while a method runs, so a lot of nil object checks could be optimized away. (Feedback case 45299)
We'll see what Xojo Inc. will reveal on future development at XDC. Be sure to join the conference and visit the sessions about the compiler to learn how it works.