What are the different levels of optimization in compiler?
Answers
Compiler optimization is generally implemented using a sequence of optimizing transformations, algorithms which take a program and transform it to produce a semantically equivalent output program that uses fewer resources. It has been shown that some code optimization problems are NP-complete, or even undecidable. In practice, factors such as the programmer's willingness to wait for the compiler to complete its task place upper limits on the optimizations that a compiler implementor might provide. (Optimization is generally a very CPU- and memory-intensive process.) In the past, computer memory limitations were also a major factor in limiting which optimizations could be performed. Because of all these factors, optimization rarely produces "optimal" output in any sense, and in fact an "optimization" may impede performance in some cases; rather, they are heuristic methods for improving resource usage in typical programs.
Answer:
The correct answer to the given question is:
There are two types of optimization in the compiler, they are :
Machine Dependent
Machine Independent
Explanation:
Code optimization in the synthesis phase is a program transformation technique that tries to improve the intermediate code by making it consume fewer resources (i.e. CPU, memory) to achieve fast machine code. than.
Types of Code Optimization: The optimization process can be broadly classified into two categories:
Machine Independent Optimization: This phase of code optimization attempts to improve the intermediate code to achieve get better target code output. The intermediate code section converted here has nothing to do with CPU registers or absolute memory locations.
Machine Dependency Optimization: Machine Dependency Optimization is performed after the target code is generated and when the code is converted according to the target machine's architecture. It deals with CPU registers and can have an absolute memory reference rather than a relative reference. Machine-dependent optimizers try to make the most of the memory hierarchy.
#SPJ2