SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Error detection recovery
Error detection recoveryError detection recovery
Error detection recoveryTech_MX
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilersVairavel C
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languagesSOMNATHMORE2
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lexAnusuya123
 
Optimization of basic blocks
Optimization of basic blocksOptimization of basic blocks
Optimization of basic blocksishwarya516
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMvikas dhakane
 
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
 
Structure of agents
Structure of agentsStructure of agents
Structure of agentsMANJULA_AP
 
Compiler Design
Compiler DesignCompiler Design
Compiler DesignMir Majid
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generationVipul Naik
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)swapnac12
 

Tendances (20)

Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Error detection recovery
Error detection recoveryError detection recovery
Error detection recovery
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Passes of compilers
Passes of compilersPasses of compilers
Passes of compilers
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lex
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Optimization of basic blocks
Optimization of basic blocksOptimization of basic blocks
Optimization of basic blocks
 
I. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHMI. AO* SEARCH ALGORITHM
I. AO* SEARCH ALGORITHM
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
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
 
Chapter 5 Syntax Directed Translation
Chapter 5   Syntax Directed TranslationChapter 5   Syntax Directed Translation
Chapter 5 Syntax Directed Translation
 
Structure of agents
Structure of agentsStructure of agents
Structure of agents
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Chapter 6 intermediate code generation
Chapter 6   intermediate code generationChapter 6   intermediate code generation
Chapter 6 intermediate code generation
 
COMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time EnvironmentsCOMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time Environments
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 

Similaire à 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
 

Similaire à Principal source of optimization in compiler design (20)

Compiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent OptimizationsCompiler Design- Machine Independent Optimizations
Compiler Design- Machine Independent Optimizations
 
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
 

Plus de 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
 

Plus de 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
 

Dernier

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
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
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Dernier (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
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...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
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 )
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

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