Coupon Accepted Successfully!


The Basics Of Code Optimization


The optimized code executes faster, provides efficient memory storage and yields better performance. Compilers can be designed to provide code optimizations.

The code optimizer sits between the front end and the code generator. This works at intermediate code generator stage, it can perform control flow analysis and data flow analysis. And does transformations to improve the intermediate code.

Optimization provided by a compiler are as below:

– Inlining small functions: this involves in repeatedly inserting the function code instead of calling it. This reduces the calling overhead and enables further optimizations. Inlining large function will make the executable large.

– Code hoisting: this involves in moving computation s outside the loop and this saves computing time.

– Dead store elimination: If the compiler detects variables which are never used , it may safely ignore many of the operations that compute their values.

– Eliminating common sub expression

– Loop unrolling: Loop exit checks costs CPU time. This tries to get rid of all checks or atleast minimize the number of checks. If it is known that the loop is only performed a certain number of time, it can be unrolled.

Test Your Skills Now!
Take a Quiz now
Reviewer Name