• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 21, 2022 |2.8K Views

Code Optimization Techniques in Compiler Design

  Share  1 Like
Description
Discussion

Optimizing any code or algorithm plays an important role in enhancing its performance in terms of decreasing time complexity, space complexity, etc. It might involve decreasing the code’s size up to much extent. So, it can be said that optimization helps in reducing the resources and space consumed, thus increasing the compilation speed.

Performing code optimization manually involves much time and the process is tedious too. So, it’s better to use a code optimizer for the same. An optimized code promotes the reusability of code. 

The code optimization procedure can be classified into two types:

Machine Independent Optimization: This optimization phase improves the intermediate code for getting better target code in output. This intermediate code doesn’t involve, in general, any CPU registers or absolute memory locations.

Machine Dependent Optimization: It is done after the generation of the target code. It generally involves CPU registers as well as absolute memory references. Such optimizers try to take maximum advantage of the memory hierarchy.

Different ways of code optimization: