Compiler optimization

Optimizing compiler:

*Compiler optimizing is a compiler that tries to minimize or maximize some attributes of an executable computer program.

*The requirements are to minimize a program's execution time, memory requirement,and power consumption.

* It has some code optimization problems are NP-complete, or even undecidable.

*We have types of Compiler optimizations are:

  • Peephole optimizations
  • local optimizations
  • global optimizations
  • Prescient store optimizations
  • Loop optimizations
  • Machine code optimizations

1.​peephole optimiztions:

* The compilation process after machine code has been generated.

*A multiplication of a value by 2 might be more efficiently executed by left-shifting the value or by adding the value to itself

2.Local optimizations:

* Information local to a basic block.

* Basic blocks have no control flow, these optimizations need very little analysis.

3.Global optimizations:

*These are also called "intraprocedural methods" and act on whole functions

*This gives them more information to work with but often makes expensive computations necessary.

*Worst case assumptions have to be made when function calls occur or global variables are accessed 

4.Prescient store optimizations

 *The process needs some way of knowing ahead of time what value will be stored by the assignment.

* The purpose of this relaxation is to allow compiler optimization to perform certain kinds of code rearrangement that preserve the semantics of properly synchronized programs

5.Loop optimizations

*These act on the statements which make up a loop, such as a for loop.

*Loop optimizations can have a significant impact because many programs spend a large percentage of their time inside loops.

6.Machine code optimization:

*These analyze the executable task image of the program after all of an executable machine code has been linked.

*Some of the techniques that can be applied in a more limited scope, such as macro compression are more effective when the entire executable task image is available for analysis.

7. link-time optimization:

*These analyze all of a program's source code.

*The greater quantity of information extracted means that optimizations can be more effective compared to when they only have access to local information.

*This kind of optimization can also allow new techniques to be performed.

Posted on by