Optimization can affect the size and execution performance of your application. In general, optimizing results in faster and smaller programs. In addition, when you optimize your code you may uncover bugs that were not evident before.
The decision to optimize for speed or for size depends on the goals for your application, and the nature of the application. When you choose options to enhance speed, the compiler generates the fastest instruction sequences possible, but these may not be the smallest possible. Similarly, when you choose options to reduce size, the compiler generates the smallest instruction sequences possible for the source code, but these may not be the fastest possible.
If program size is more important, optimize for size. If speed is more important, optimize for speed. However, it is important to note that for larger programs which are not compute-intensive, optimizing for size might result in a faster program than one optimized for speed. This is because global effects such as improved paging and cache performance may outweigh the local effects of slower instruction sequences.
If both size and speed are important, consider balancing the performance by optimizing some modules for speed, and others for size. Determine which modules contain hotspots, and are compute-intensive: these should be optimized for speed. All other modules should be optimized for size. To find the right balance, you may need to experiment with different combinations of techniques.
Do not optimize your code only at the end of your development cycle. Develop, test, and optimize incrementally rather than developing and testing and then optimizing the entire application at the end.