SlideShare a Scribd company logo
1 of 16
PRINCPAL SOURCES OF OPTIMISATION
R. Rajkumar
AP | CSE
SRM IST
UNIT 5
Principle SOURCES OF OPTIMISATION
•A compiler optimization must preserve the semantics of the
original program.
•Except in very special circumstances, once a programmer
chooses and implements a particular algorithm, the compiler
cannot understand enough about the program to replace it
with a substantially different and more efficient algorithm.
•A compiler knows only how to apply relatively low-level
semantic transformations, using general facts.
Function-Preserving Transformations
There are a number of ways in which a compiler can improve a
program without changing the function it computes.
Function preserving transformations examples:
• 1. Common sub expression elimination
• 2. Copy propagation,
• 3. Dead-code elimination
• 4. Constant folding
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
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
the 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.
• 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.
Example:
i=0;
if(i=1)
{
a=b+5;
} Here, ‘if’ statement is dead code because this condition will never get satisfied.
Constant folding:
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
In loops, especially in the inner loops, programs tend to spend the bulk of
their time. The running time of a program may be improved if the number of
instructions in an inner loop is decreased, 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.
Data flow analysis
• It is the analysis of flow of data in control flow graph, i.e., the analysis
that determines the information regarding the definition and use of
data in program. With the help of this analysis optimization can be
done. In general, its process in which values are computed using data
flow analysis. The data flow property represents information which
can be used for optimization.
Data flow analysis
A expression is said to be available at a program point x iff along paths its reaching to x.
A Expression is available at its evaluation point.
A expression a+b is said to be available if none of the operands gets modified before their use.
Example
AVAILABLE EXPRESSION
Reaching Definition
• A definition D is reaches a point x if there is path from D to x in
which D is not killed, i.e., not redefined.
Live variable
A variable is said to be live at some point p if from p to end the
variable is used before it is redefined else it becomes dead.
Advantages:
It is useful for register allocation.
It is used in dead code elimination.
Summary
• Principle Sources of Optimisation
• Function-Preserving Transformations
• Common Sub expressions elimination:
• Copy Propagation:
• Dead-Code Eliminations:
• Constant folding:
• Loop Optimizations
• Data flow analysis
• Available Expression
• Reaching Definition
• Live variable

More Related Content

What's hot

Substitution techniques
Substitution techniquesSubstitution techniques
Substitution techniquesvinitha96
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agentsMegha Sharma
 
Code optimisation presnted
Code optimisation presntedCode optimisation presnted
Code optimisation presntedbhavanatmithun
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption StandardPrince Rachit
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cflSampath Kumar S
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithmswapnac12
 
Communication primitives
Communication primitivesCommunication primitives
Communication primitivesStudent
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler designRiazul Islam
 
Lecture 16 memory bounded search
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded searchHema Kashyap
 
Public Key Cryptosystem
Public Key CryptosystemPublic Key Cryptosystem
Public Key CryptosystemDevakumar Kp
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithmBushra M
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Water jug problem ai part 6
Water jug problem ai part 6Water jug problem ai part 6
Water jug problem ai part 6Kirti Verma
 

What's hot (20)

Substitution techniques
Substitution techniquesSubstitution techniques
Substitution techniques
 
Problem solving agents
Problem solving agentsProblem solving agents
Problem solving agents
 
Code optimisation presnted
Code optimisation presntedCode optimisation presnted
Code optimisation presnted
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption Standard
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithm
 
Communication primitives
Communication primitivesCommunication primitives
Communication primitives
 
Finite Automata in compiler design
Finite Automata in compiler designFinite Automata in compiler design
Finite Automata in compiler design
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Lecture 16 memory bounded search
Lecture 16 memory bounded searchLecture 16 memory bounded search
Lecture 16 memory bounded search
 
Compiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent OptimizationsCompiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent Optimizations
 
Public Key Cryptosystem
Public Key CryptosystemPublic Key Cryptosystem
Public Key Cryptosystem
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Water jug problem ai part 6
Water jug problem ai part 6Water jug problem ai part 6
Water jug problem ai part 6
 

Similar to Principal source of optimization in compiler design

Compiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statementsCompiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statementsGeo Marian
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
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
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxchandankumar364348
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptxManas40552
 
detail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfdetail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfssuserf86fba
 
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
Algorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTSAlgorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTS
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTSAlicia Edwards
 
User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions in CRAJ KUMAR
 
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
 

Similar to Principal source of optimization in compiler design (20)

Code Optimizatoion
Code OptimizatoionCode Optimizatoion
Code Optimizatoion
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Functions in C++.pdf
Functions in C++.pdfFunctions in C++.pdf
Functions in C++.pdf
 
Compiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statementsCompiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statements
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Programming in c by pkv
Programming in c by pkvProgramming in c by pkv
Programming in c by pkv
 
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
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptx
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
85ec7 session2 c++
85ec7 session2 c++85ec7 session2 c++
85ec7 session2 c++
 
detail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfdetail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdf
 
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
Algorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTSAlgorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTS
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
 
Algorithm manual
Algorithm manualAlgorithm manual
Algorithm manual
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
 
c programming2.pptx
c programming2.pptxc programming2.pptx
c programming2.pptx
 
User Defined Functions in C
User Defined Functions in CUser Defined Functions in C
User Defined Functions 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
 

More from Rajkumar R

Dr. R. Rajkumar Environment .pptx
Dr. R. Rajkumar Environment .pptxDr. R. Rajkumar Environment .pptx
Dr. R. Rajkumar Environment .pptxRajkumar R
 
Health is wealth - Swetha presentation
Health is wealth - Swetha presentationHealth is wealth - Swetha presentation
Health is wealth - Swetha presentationRajkumar R
 
Cloud computing on medical R. Rajkumar
Cloud computing on medical   R. RajkumarCloud computing on medical   R. Rajkumar
Cloud computing on medical R. RajkumarRajkumar R
 
How to from good design to great design
How to from good design to great design How to from good design to great design
How to from good design to great design Rajkumar R
 
Business opportunities in ed tech
Business opportunities in ed techBusiness opportunities in ed tech
Business opportunities in ed techRajkumar R
 
Machine learning in human computer interface
Machine learning in human computer interfaceMachine learning in human computer interface
Machine learning in human computer interfaceRajkumar R
 
FDP on AI and ML by R. Rajkumar
FDP on AI and ML by  R. RajkumarFDP on AI and ML by  R. Rajkumar
FDP on AI and ML by R. RajkumarRajkumar R
 
Tamil Teaching methods for Higher Education
Tamil Teaching methods for Higher Education Tamil Teaching methods for Higher Education
Tamil Teaching methods for Higher Education Rajkumar R
 
Virtual reality for all
Virtual reality for allVirtual reality for all
Virtual reality for allRajkumar R
 
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSE
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSEAI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSE
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSERajkumar R
 
Webinar on oppurtunities on industry 4.0
Webinar on oppurtunities on industry 4.0Webinar on oppurtunities on industry 4.0
Webinar on oppurtunities on industry 4.0Rajkumar R
 
Finger print presentation by R Rajkumar
Finger print presentation by R Rajkumar Finger print presentation by R Rajkumar
Finger print presentation by R Rajkumar Rajkumar R
 
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by Rajkumar
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by RajkumarWebinar on AI in IoT applications KCG Connect Alumni Digital Series by Rajkumar
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by RajkumarRajkumar R
 

More from Rajkumar R (13)

Dr. R. Rajkumar Environment .pptx
Dr. R. Rajkumar Environment .pptxDr. R. Rajkumar Environment .pptx
Dr. R. Rajkumar Environment .pptx
 
Health is wealth - Swetha presentation
Health is wealth - Swetha presentationHealth is wealth - Swetha presentation
Health is wealth - Swetha presentation
 
Cloud computing on medical R. Rajkumar
Cloud computing on medical   R. RajkumarCloud computing on medical   R. Rajkumar
Cloud computing on medical R. Rajkumar
 
How to from good design to great design
How to from good design to great design How to from good design to great design
How to from good design to great design
 
Business opportunities in ed tech
Business opportunities in ed techBusiness opportunities in ed tech
Business opportunities in ed tech
 
Machine learning in human computer interface
Machine learning in human computer interfaceMachine learning in human computer interface
Machine learning in human computer interface
 
FDP on AI and ML by R. Rajkumar
FDP on AI and ML by  R. RajkumarFDP on AI and ML by  R. Rajkumar
FDP on AI and ML by R. Rajkumar
 
Tamil Teaching methods for Higher Education
Tamil Teaching methods for Higher Education Tamil Teaching methods for Higher Education
Tamil Teaching methods for Higher Education
 
Virtual reality for all
Virtual reality for allVirtual reality for all
Virtual reality for all
 
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSE
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSEAI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSE
AI and covid19 | Mr. R. Rajkumar, Assistant Professor, Department of CSE
 
Webinar on oppurtunities on industry 4.0
Webinar on oppurtunities on industry 4.0Webinar on oppurtunities on industry 4.0
Webinar on oppurtunities on industry 4.0
 
Finger print presentation by R Rajkumar
Finger print presentation by R Rajkumar Finger print presentation by R Rajkumar
Finger print presentation by R Rajkumar
 
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by Rajkumar
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by RajkumarWebinar on AI in IoT applications KCG Connect Alumni Digital Series by Rajkumar
Webinar on AI in IoT applications KCG Connect Alumni Digital Series by Rajkumar
 

Recently uploaded

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 

Recently uploaded (20)

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 

Principal source of optimization in compiler design

  • 1. PRINCPAL SOURCES OF OPTIMISATION R. Rajkumar AP | CSE SRM IST UNIT 5
  • 2. Principle SOURCES OF OPTIMISATION •A compiler optimization must preserve the semantics of the original program. •Except in very special circumstances, once a programmer chooses and implements a particular algorithm, the compiler cannot understand enough about the program to replace it with a substantially different and more efficient algorithm. •A compiler knows only how to apply relatively low-level semantic transformations, using general facts.
  • 3. Function-Preserving Transformations There are a number of ways in which a compiler can improve a program without changing the function it computes. Function preserving transformations examples: • 1. Common sub expression elimination • 2. Copy propagation, • 3. Dead-code elimination • 4. Constant folding
  • 4. 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.
  • 5. For example t1: = 4*i t2: = a [t1] t3: = 4*j t4: = 4*i t5: = n t6: = b [t4] +t5 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 the value of i is not been changed from definition to use.]
  • 6. 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. • 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
  • 7. 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. Example: i=0; if(i=1) { a=b+5; } Here, ‘if’ statement is dead code because this condition will never get satisfied.
  • 8. Constant folding: 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.
  • 9. Loop Optimizations In loops, especially in the inner loops, programs tend to spend the bulk of their time. The running time of a program may be improved if the number of instructions in an inner loop is decreased, 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.
  • 10.
  • 11. Data flow analysis • It is the analysis of flow of data in control flow graph, i.e., the analysis that determines the information regarding the definition and use of data in program. With the help of this analysis optimization can be done. In general, its process in which values are computed using data flow analysis. The data flow property represents information which can be used for optimization.
  • 13. A expression is said to be available at a program point x iff along paths its reaching to x. A Expression is available at its evaluation point. A expression a+b is said to be available if none of the operands gets modified before their use. Example AVAILABLE EXPRESSION
  • 14. Reaching Definition • A definition D is reaches a point x if there is path from D to x in which D is not killed, i.e., not redefined.
  • 15. Live variable A variable is said to be live at some point p if from p to end the variable is used before it is redefined else it becomes dead. Advantages: It is useful for register allocation. It is used in dead code elimination.
  • 16. Summary • Principle Sources of Optimisation • Function-Preserving Transformations • Common Sub expressions elimination: • Copy Propagation: • Dead-Code Eliminations: • Constant folding: • Loop Optimizations • Data flow analysis • Available Expression • Reaching Definition • Live variable