SlideShare a Scribd company logo
1 of 18
PRINCIPAL SOURCES OF OPTIMAZATION
Presented by
S.Sivasathya
BP150510
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.
 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.
 Flow analysis is a fundamental prerequisite for many important
types of code improvement.
CONT.…..
 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 ascerting 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.
PRINCIPAL SOURCES OF OPTIMIZATION
 A transformation of a program is called local if it can be
performed by looking only at the statements in a basic block;
otherwise, it is called global.
 Many transformations can be performed at both the local and
global levels. Local transformations are usually performed first.
Function-Preserving Transformations
 There are a number of ways in which a compiler can improve a
program without changing the function it computes.
CONT.…..
The transformations:
 Common sub expression elimination,
 Copy propagation,
 Dead-code elimination, and
 Constant folding
 are common examples of such function-preserving
transformations.
 The other transformations come up primarily when global
optimizations are performed.
 Frequently, a program will include several calculations of the
same value, such as an offset in an array. Some of the
duplicate calculations cannot be avoided by the programmer
because they lie below the level of detail accessible within the
source language.
Common Sub expressions elimination:
 An occurrence of an expression E is called a common sub-
expression if E was previously computed, and the values of
variables in E have not changed since the previous computation.
We can avoid recomputing the expression if we can use the
previously computed value.
 For example
 t1: = 4*i
 t2: = a [t1]
 t3: = 4*j
 t4: = 4*i
 t5: = n
 t6: = b [t4] +t5
CONT.……
 The above code can be optimized using the common sub-expression
elimination as
 t1: = 4*i
 t2: = a [t1]
 t3: = 4*j
 t5: = n
 t6: = b [t1] +t5
 The common sub expression t4: =4*i is eliminated as its
computation is already in t1. And value of i is not been changed
from definition to use.
Copy Propagation:
 Assignments of the form f : = g called copy statements, or copies for
short.
 The idea behind the copy-propagation transformation is to use g for
f, whenever possible after the copy statement f: = g.
 Copy propagation means use of one variable instead of another.
 This may not appear to be an improvement, but as we shall see it
gives us an opportunity to eliminate x.
CONT.….
For example:
 x=Pi;
 ……
 A=x*r*r;
 The optimization using copy propagation can be done as follows:
 A=Pi*r*r;
 Here the variable x is eliminated
Dead-Code Eliminations:
 A variable is live at a point in a program if its value can be used
subsequently; otherwise, it is dead at that point.
 A related idea is dead or useless code, statements that compute
values that never get used.
 While the programmer is unlikely to introduce any dead code
intentionally ,it may appear as the result of previous
transformations.
An optimization can be done by eliminating dead code.
 Example:
 i=0;
 if(i=1)
 {
 a=b+5;
 }
CONT.….
 Here, ‘if’ statement is dead code because this condition will never
get satisfied.
 We can eliminate both the test and printing from the object code.
More generally,
 deducing at compile time that the value of an expression is a
constant and using the
 constant instead is known as constant folding.
 One advantage of copy propagation is that it often turns the copy
statement into dead
 code.
 For example,
 a=3.14157/2 can be replaced by
 a=1.570 there by eliminating a division operation.
Loop Optimizations:
 We now give a brief introduction to a very important place for
optimizations, namely loops, especially the inner loops where
programs tend to spend the bulk of their time.
 The running time of a program may be improved if we decrease the
number of instructions in an inner loop, even if we increase the
amount of code outside that loop.
 Three techniques are important for loop optimization:
 code motion, which moves code outside a loop;
 Induction-variable elimination, which we apply to replace
variables from inner loop.
 Reduction in strength, which replaces and expensive operation by
a cheaper one, such as a multiplication by an addition.
Code Motion:
 An important modification that decreases the amount of code in a
loop is code motion.
 This transformation takes an expression that yields the same result
independent of the number of times a loop is executed ( a loop-
invariant computation) and places the expression before the loop.
 Note that the notion “before the loop” assumes the existence of an
entry for the loop.
 For example, evaluation of limit-2 is a loop-invariant computation in
the following while-statement:
 while (i <= limit-2) /* statement does not change limit*/
 Code motion will result in the equivalent of
 t= limit-2;
 while (i<=t) /* statement does not change limit or t */
Induction Variables :
 Loops are usually processed inside out. For example consider the loop
around B3.
 Note that the values of j and t4 remain in lock-step; every time the
value of j decreases by 1, that of t4 decreases by 4 because 4*j is
assigned to t4. Such identifiers are called induction variables.
 When there are two or more induction variables in a loop, it may be
possible to get rid of all but one, by the process of induction-variable
elimination. For the inner loop around B3 in Fig. we cannot get rid of
either j or t4 completely; t4 is used in B3 and j in B4.
 However, we can illustrate reduction in strength and illustrate a part of
the process of induction-variable elimination.
 Eventually j will be eliminated when the outer loop of B2- B5 is
considered.
Example:
 As the relationship t4:=4*j surely holds after such an assignment to
t4 in Fig. and t4 is not changed elsewhere in the inner loop around
B3, it follows that just after the statement j:=j-1 the relationship t4:=
4*j-4 must hold.
 We may therefore replace the assignment t4:=4*j by t4:= t4-4. The
only problem is that t4 does not have a value when we enter block
B3 for the first time.
 Since we must maintain the relationship t4=4*j on entry to the
block B3, we place an initializations of t4 at the end of the block
where j itself is The replacement of a multiplication by a subtraction
will speed up the object code if multiplication takes more time than
addition or subtraction, as is the case on many machines.
Thank You

More Related Content

What's hot

Partial redundancy elimination
Partial redundancy eliminationPartial redundancy elimination
Partial redundancy eliminationIshucs
 
Learning rule of first order rules
Learning rule of first order rulesLearning rule of first order rules
Learning rule of first order rulesswapnac12
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code GeneratorDarshan sai Reddy
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithmswapnac12
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Basic blocks - compiler design
Basic blocks - compiler designBasic blocks - compiler design
Basic blocks - compiler designhmnasim15
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure callSunita Sahu
 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSARASWATHI S
 
Optimization of basic blocks
Optimization of basic blocksOptimization of basic blocks
Optimization of basic blocksishwarya516
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software conceptsPrajakta Rane
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 

What's hot (20)

Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Partial redundancy elimination
Partial redundancy eliminationPartial redundancy elimination
Partial redundancy elimination
 
Code generation
Code generationCode generation
Code generation
 
Learning rule of first order rules
Learning rule of first order rulesLearning rule of first order rules
Learning rule of first order rules
 
Issues in the design of Code Generator
Issues in the design of Code GeneratorIssues in the design of Code Generator
Issues in the design of Code Generator
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithm
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Basic blocks - compiler design
Basic blocks - compiler designBasic blocks - compiler design
Basic blocks - compiler design
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
RPC: Remote procedure call
RPC: Remote procedure callRPC: Remote procedure call
RPC: Remote procedure call
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
1.Role lexical Analyzer
1.Role lexical Analyzer1.Role lexical Analyzer
1.Role lexical Analyzer
 
System software - macro expansion,nested macro calls
System software - macro expansion,nested macro callsSystem software - macro expansion,nested macro calls
System software - macro expansion,nested macro calls
 
Optimization of basic blocks
Optimization of basic blocksOptimization of basic blocks
Optimization of basic blocks
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts2. Distributed Systems Hardware & Software concepts
2. Distributed Systems Hardware & Software concepts
 
Three Address code
Three Address code Three Address code
Three Address code
 

Viewers also liked

How One Billion Salesforce records Can Be Replicated with Minimal API Usage
How One Billion Salesforce records Can Be Replicated with Minimal API UsageHow One Billion Salesforce records Can Be Replicated with Minimal API Usage
How One Billion Salesforce records Can Be Replicated with Minimal API UsageBaruch Oxman
 
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...2008 IFAC World Congress: Oil and gas production optimization - lost potentia...
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...Steinar Elgsæter
 
Smart Process Operations in Fuels Industries: Applications and Opportunities ...
Smart Process Operations in Fuels Industries: Applications and Opportunities ...Smart Process Operations in Fuels Industries: Applications and Opportunities ...
Smart Process Operations in Fuels Industries: Applications and Opportunities ...Brenno Menezes
 
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...Ryan Dinn
 
Modeling and Optimization of In-Situ Oil Production
Modeling and Optimization of In-Situ Oil ProductionModeling and Optimization of In-Situ Oil Production
Modeling and Optimization of In-Situ Oil ProductionAlvaro Gil
 
Inside the Force.com Query Optimizer Webinar
Inside the Force.com Query Optimizer WebinarInside the Force.com Query Optimizer Webinar
Inside the Force.com Query Optimizer WebinarSalesforce Developers
 
Biogas technology - A renewable source of energy
Biogas technology - A renewable source of energyBiogas technology - A renewable source of energy
Biogas technology - A renewable source of energyJanak Shah
 
Crude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimizationCrude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimizationBrenno Menezes
 
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZER
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZERINTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZER
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZERMARROS LESTARI
 
Understanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoUnderstanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoSalesforce Developers
 
A Study Of Production Optimization Of An Oil Copy
A Study Of Production Optimization Of An Oil   CopyA Study Of Production Optimization Of An Oil   Copy
A Study Of Production Optimization Of An Oil Copyaadrish
 
Biogas plant designs and engery calculations by ali saqlain
Biogas plant designs and engery calculations by ali saqlainBiogas plant designs and engery calculations by ali saqlain
Biogas plant designs and engery calculations by ali saqlainali saqlain
 
Crude-Oil Blend Scheduling Optimization: An Application with Multi-Million D...
Crude-Oil Blend Scheduling Optimization:  An Application with Multi-Million D...Crude-Oil Blend Scheduling Optimization:  An Application with Multi-Million D...
Crude-Oil Blend Scheduling Optimization: An Application with Multi-Million D...Alkis Vazacopoulos
 
Oil-Refinery Planning & Scheduling Optimization
Oil-Refinery Planning & Scheduling OptimizationOil-Refinery Planning & Scheduling Optimization
Oil-Refinery Planning & Scheduling OptimizationAlkis Vazacopoulos
 

Viewers also liked (20)

How One Billion Salesforce records Can Be Replicated with Minimal API Usage
How One Billion Salesforce records Can Be Replicated with Minimal API UsageHow One Billion Salesforce records Can Be Replicated with Minimal API Usage
How One Billion Salesforce records Can Be Replicated with Minimal API Usage
 
Process Optimization & Slop Oil Reduction( Fahad Khan)
Process Optimization & Slop Oil Reduction( Fahad Khan)Process Optimization & Slop Oil Reduction( Fahad Khan)
Process Optimization & Slop Oil Reduction( Fahad Khan)
 
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...2008 IFAC World Congress: Oil and gas production optimization - lost potentia...
2008 IFAC World Congress: Oil and gas production optimization - lost potentia...
 
Smart Process Operations in Fuels Industries: Applications and Opportunities ...
Smart Process Operations in Fuels Industries: Applications and Opportunities ...Smart Process Operations in Fuels Industries: Applications and Opportunities ...
Smart Process Operations in Fuels Industries: Applications and Opportunities ...
 
Modelling, Simulation and Optimization of Refining Processes
Modelling, Simulation and Optimization of Refining ProcessesModelling, Simulation and Optimization of Refining Processes
Modelling, Simulation and Optimization of Refining Processes
 
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...
Chemical Engineering Design II Final Project - Optimization of Heavy Oil Stri...
 
Supply chain
Supply chainSupply chain
Supply chain
 
Modeling and Optimization of In-Situ Oil Production
Modeling and Optimization of In-Situ Oil ProductionModeling and Optimization of In-Situ Oil Production
Modeling and Optimization of In-Situ Oil Production
 
Inside the Force.com Query Optimizer Webinar
Inside the Force.com Query Optimizer WebinarInside the Force.com Query Optimizer Webinar
Inside the Force.com Query Optimizer Webinar
 
Biogas technology - A renewable source of energy
Biogas technology - A renewable source of energyBiogas technology - A renewable source of energy
Biogas technology - A renewable source of energy
 
Crude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimizationCrude-Oil Scheduling Technology: moving from simulation to optimization
Crude-Oil Scheduling Technology: moving from simulation to optimization
 
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZER
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZERINTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZER
INTEGRATED COW FARM-BIOGAS-ORGANIC FERTILIZER
 
Biogas technology
Biogas technologyBiogas technology
Biogas technology
 
Understanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoUnderstanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We Do
 
Oil & gas
Oil & gasOil & gas
Oil & gas
 
A Study Of Production Optimization Of An Oil Copy
A Study Of Production Optimization Of An Oil   CopyA Study Of Production Optimization Of An Oil   Copy
A Study Of Production Optimization Of An Oil Copy
 
Biogas plant designs and engery calculations by ali saqlain
Biogas plant designs and engery calculations by ali saqlainBiogas plant designs and engery calculations by ali saqlain
Biogas plant designs and engery calculations by ali saqlain
 
BIOGAS for Everyone : Simplified for all
BIOGAS for Everyone : Simplified for all BIOGAS for Everyone : Simplified for all
BIOGAS for Everyone : Simplified for all
 
Crude-Oil Blend Scheduling Optimization: An Application with Multi-Million D...
Crude-Oil Blend Scheduling Optimization:  An Application with Multi-Million D...Crude-Oil Blend Scheduling Optimization:  An Application with Multi-Million D...
Crude-Oil Blend Scheduling Optimization: An Application with Multi-Million D...
 
Oil-Refinery Planning & Scheduling Optimization
Oil-Refinery Planning & Scheduling OptimizationOil-Refinery Planning & Scheduling Optimization
Oil-Refinery Planning & Scheduling Optimization
 

Similar to Principle source of optimazation

Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptxzueZ3
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdfHome
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFaisal Shehzad
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxSangeetaBorde3
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in Cbhawna kol
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c languageTanmay Modi
 
Chapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdfChapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdfKirubelWondwoson1
 

Similar to Principle source of optimazation (20)

Code optimization
Code optimizationCode optimization
Code optimization
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptx
 
Inline function
Inline functionInline function
Inline function
 
Code Optimizatoion
Code OptimizatoionCode Optimizatoion
Code Optimizatoion
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
Operators
OperatorsOperators
Operators
 
c_programming.pdf
c_programming.pdfc_programming.pdf
c_programming.pdf
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal ShahzadFunction Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
Function Overloading,Inline Function and Recursion in C++ By Faisal Shahzad
 
Function in C++
Function in C++Function in C++
Function in C++
 
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptxCH.4FUNCTIONS IN C_FYBSC(CS).pptx
CH.4FUNCTIONS IN C_FYBSC(CS).pptx
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
 
Chapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdfChapter 5 - Modular Programming.pdf
Chapter 5 - Modular Programming.pdf
 
Functions in C++.pdf
Functions in C++.pdfFunctions in C++.pdf
Functions in C++.pdf
 
Function C programming
Function C programmingFunction C programming
Function C programming
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

Principle source of optimazation

  • 1. PRINCIPAL SOURCES OF OPTIMAZATION Presented by S.Sivasathya BP150510
  • 2. 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.  Machine independent optimizations:  Machine dependant optimizations:
  • 3. 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.  Flow analysis is a fundamental prerequisite for many important types of code improvement.
  • 4. CONT.…..  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 ascerting 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.
  • 5. PRINCIPAL SOURCES OF OPTIMIZATION  A transformation of a program is called local if it can be performed by looking only at the statements in a basic block; otherwise, it is called global.  Many transformations can be performed at both the local and global levels. Local transformations are usually performed first. Function-Preserving Transformations  There are a number of ways in which a compiler can improve a program without changing the function it computes.
  • 6. CONT.….. The transformations:  Common sub expression elimination,  Copy propagation,  Dead-code elimination, and  Constant folding  are common examples of such function-preserving transformations.  The other transformations come up primarily when global optimizations are performed.  Frequently, a program will include several calculations of the same value, such as an offset in an array. Some of the duplicate calculations cannot be avoided by the programmer because they lie below the level of detail accessible within the source language.
  • 7. Common Sub expressions elimination:  An occurrence of an expression E is called a common sub- expression if E was previously computed, and the values of variables in E have not changed since the previous computation. We can avoid recomputing the expression if we can use the previously computed value.  For example  t1: = 4*i  t2: = a [t1]  t3: = 4*j  t4: = 4*i  t5: = n  t6: = b [t4] +t5
  • 8. CONT.……  The above code can be optimized using the common sub-expression elimination as  t1: = 4*i  t2: = a [t1]  t3: = 4*j  t5: = n  t6: = b [t1] +t5  The common sub expression t4: =4*i is eliminated as its computation is already in t1. And value of i is not been changed from definition to use.
  • 9. Copy Propagation:  Assignments of the form f : = g called copy statements, or copies for short.  The idea behind the copy-propagation transformation is to use g for f, whenever possible after the copy statement f: = g.  Copy propagation means use of one variable instead of another.  This may not appear to be an improvement, but as we shall see it gives us an opportunity to eliminate x.
  • 10. CONT.…. For example:  x=Pi;  ……  A=x*r*r;  The optimization using copy propagation can be done as follows:  A=Pi*r*r;  Here the variable x is eliminated
  • 11. Dead-Code Eliminations:  A variable is live at a point in a program if its value can be used subsequently; otherwise, it is dead at that point.  A related idea is dead or useless code, statements that compute values that never get used.  While the programmer is unlikely to introduce any dead code intentionally ,it may appear as the result of previous transformations. An optimization can be done by eliminating dead code.  Example:  i=0;  if(i=1)  {  a=b+5;  }
  • 12. CONT.….  Here, ‘if’ statement is dead code because this condition will never get satisfied.  We can eliminate both the test and printing from the object code. More generally,  deducing at compile time that the value of an expression is a constant and using the  constant instead is known as constant folding.  One advantage of copy propagation is that it often turns the copy statement into dead  code.  For example,  a=3.14157/2 can be replaced by  a=1.570 there by eliminating a division operation.
  • 13. Loop Optimizations:  We now give a brief introduction to a very important place for optimizations, namely loops, especially the inner loops where programs tend to spend the bulk of their time.  The running time of a program may be improved if we decrease the number of instructions in an inner loop, even if we increase the amount of code outside that loop.  Three techniques are important for loop optimization:  code motion, which moves code outside a loop;  Induction-variable elimination, which we apply to replace variables from inner loop.  Reduction in strength, which replaces and expensive operation by a cheaper one, such as a multiplication by an addition.
  • 14. Code Motion:  An important modification that decreases the amount of code in a loop is code motion.  This transformation takes an expression that yields the same result independent of the number of times a loop is executed ( a loop- invariant computation) and places the expression before the loop.  Note that the notion “before the loop” assumes the existence of an entry for the loop.  For example, evaluation of limit-2 is a loop-invariant computation in the following while-statement:  while (i <= limit-2) /* statement does not change limit*/  Code motion will result in the equivalent of  t= limit-2;  while (i<=t) /* statement does not change limit or t */
  • 15. Induction Variables :  Loops are usually processed inside out. For example consider the loop around B3.  Note that the values of j and t4 remain in lock-step; every time the value of j decreases by 1, that of t4 decreases by 4 because 4*j is assigned to t4. Such identifiers are called induction variables.  When there are two or more induction variables in a loop, it may be possible to get rid of all but one, by the process of induction-variable elimination. For the inner loop around B3 in Fig. we cannot get rid of either j or t4 completely; t4 is used in B3 and j in B4.  However, we can illustrate reduction in strength and illustrate a part of the process of induction-variable elimination.  Eventually j will be eliminated when the outer loop of B2- B5 is considered.
  • 16. Example:  As the relationship t4:=4*j surely holds after such an assignment to t4 in Fig. and t4 is not changed elsewhere in the inner loop around B3, it follows that just after the statement j:=j-1 the relationship t4:= 4*j-4 must hold.  We may therefore replace the assignment t4:=4*j by t4:= t4-4. The only problem is that t4 does not have a value when we enter block B3 for the first time.  Since we must maintain the relationship t4=4*j on entry to the block B3, we place an initializations of t4 at the end of the block where j itself is The replacement of a multiplication by a subtraction will speed up the object code if multiplication takes more time than addition or subtraction, as is the case on many machines.
  • 17.