C Code Optimization Techniques
Optimization is a coding activity. In traditional software development processes, optimization takes place after Code Complete, during the integration and testing phase of a project, when the performance of a whole program can be observed. In an Agile development process, one or more sprints may be allocated to optimization after a feature with performance goals is coded, or as needed to meet performance targets. The goal of optimization is to improve the behavior of a correct program so that it also meets customer needs for speed, throughput, memory footprint, power consumption, and so on. Optimization is thus as important to the development process as coding features are. …
Below are the techniques for loop optimization.
Functions can be instructed to the compiler to make them inline so that the compiler can replace those function definitions wherever called. It saves the overhead of variable push/pop on the stack, which was required for function calling and also reduces the overhead of return from the function. At the same time, the inline function will tend to increase the code size.
Loop jamming reduces code size and makes code run faster as well by eliminating the loop iteration overhead.