Code Optimization, Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

Computer Science Engineering (CSE) : Code Optimization, Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

The document Code Optimization, Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev is a part of Computer Science Engineering (CSE) category.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

CODE OPTIMIZATION

INTRODUCTION

The code produced by the straight forward compiling algorithms can often be made to run faster or take less space, or both. This improvement is achieved by program transformations that are traditionally called optimizations. Compilers that apply code-improving transformations are called optimizing compilers.

Optimizations are classified into two categories. They are

  •  Machine independent optimizations:
  • Machine dependant optimizations:

 

Machine independent optimizations:

  • Machine independent optimizations are program transformations that improve the target code without taking into consideration any properties of the target machine.

Machine dependant optimizations:

  • Machine dependant optimizations are based on register allocation and utilization of special machine-instruction sequences.

 

The criteria for code improvement transformations:

Simply stated, the best program transformations are those that yield the most benefit for the least effort. The transformations provided by an optimizing compiler should have several properties. They are:

1.     The transformation must preserve the meaning of programs. That is, the optimization must not change the output produced by a program for a given input, or cause an error such as division by zero, that was not present in the original source program.

Code Optimization, Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

2.     A transformation must, on the average, speedup programs by a measurable amount. We are also interested in reducing the size of the compiled code although the size of the code has less importance than it once had. Not every transformation succeeds in improving every program, occasionally an “optimization” may slow down a program slightly.

3.     The transformation must be worth the effort. It does not make sense for a compiler writer to expend the intellectual effort to implement a code improving transformation and have the compiler expend the additional time compiling source programs if this effort is not repaid when the target programs are executed. “Peephole” transformations of this kind are simple enough and beneficial enough to be included in any compiler.

Flow analysis is a fundamental prerequisite for many important types of code improvement. Generally control flow analysis precedes data flow analysis. Control flow analysis (CFA) represents flow of control usually in form of graphs, CFA constructs such as control flow graph, Call graph. Data flow analysis (DFA) is the process of asserting and collecting information prior to program execution about the possible modification, preservation, and use of certain entities (such as values or attributes of variables) in a computer program.

Offer running on EduRev: Apply code STAYHOME200 to get INR 200 off on our premium plan EduRev Infinity!

Related Searches

mock tests for examination

,

Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

,

Code Optimization

,

Exam

,

Extra Questions

,

Code Optimization

,

pdf

,

Semester Notes

,

Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

,

Sample Paper

,

Viva Questions

,

Computer Science and IT Engineering Computer Science Engineering (CSE) Notes | EduRev

,

shortcuts and tricks

,

Previous Year Questions with Solutions

,

study material

,

Summary

,

practice quizzes

,

video lectures

,

Objective type Questions

,

ppt

,

MCQs

,

past year papers

,

Important questions

,

Code Optimization

,

Free

;