SlideShare a Scribd company logo

Peephole optimization techniques

garishma bhatia
garishma bhatia
garishma bhatiaStudent at gehu bhimtal

compiler design - Peephole optimization techniques

Peephole optimization techniques

1 of 10
Download to read offline
Peephole Optimization
Techniques
By : GARISHMA BHATIA
CONTENT
 What is an Peephole Optimization
 Types of Optimization Techniques
 What is an Optimization
 Replacement Rules
 Example
 Conclusion
 References
What is Optimization?
 Optimization is the process of transforming a piece of code to make more
efficient(either in terms of time or space) without changing its output.
 The only difference visible to the user should be that it runs faster and/or consumes less
memory.
Types of Optimization
 Optimization can be categorized broadly into two types :
 Machine Independent
 Machine dependent
Machine-independent Optimization
 The compiler takes in the intermediate code and transforms a part of the code that does not
involve any CPU registers and/or absolute memory locations.
 For example
do {
item = 10;
value = value + item ;
}
While(value<100);
This code involves repeated assignment of the identifier item, which if we put this way:
Item = 10;
do {
value = value + item ;
}
while(value<100);
It should not only save the CPU cycles, but can be used on any processor.
Ad

Recommended

Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler designAnul Chaudhary
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design Syntax Analysis in Compiler Design
Syntax Analysis in Compiler Design MAHASREEM
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow GraphsJenny Galino
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 

More Related Content

What's hot

Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control UnitKamal Acharya
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processorMuhammad Ishaq
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventionssaranyatdr
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design BasicsAkhil Kaushik
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 
Command line arguments
Command line argumentsCommand line arguments
Command line argumentsAshok Raj
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output OrganizationKamal Acharya
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler DesignShine Raj
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle pptsheetal singh
 
code optimization
code optimization code optimization
code optimization Sanjeev Raaz
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 

What's hot (20)

Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Superscalar & superpipeline processor
Superscalar & superpipeline processorSuperscalar & superpipeline processor
Superscalar & superpipeline processor
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Addressing sequencing
Addressing sequencingAddressing sequencing
Addressing sequencing
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Three Address code
Three Address code Three Address code
Three Address code
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
 
Three address code In Compiler Design
Three address code In Compiler DesignThree address code In Compiler Design
Three address code In Compiler Design
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle ppt
 
code optimization
code optimization code optimization
code optimization
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 

Similar to Peephole optimization techniques

Peephole optimization
Peephole optimization Peephole optimization
Peephole optimization Mvidhya9
 
Cse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionCse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionShobha Kumar
 
Instruction compression techniques
Instruction compression techniquesInstruction compression techniques
Instruction compression techniquesSudhanshu Janwadkar
 
Automatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole SuperoptimizersAutomatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole Superoptimizerskeanumit
 
Compiler Optimization-Space Exploration
Compiler Optimization-Space ExplorationCompiler Optimization-Space Exploration
Compiler Optimization-Space Explorationtmusabbir
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Junade Ali
 
Best Practices and Performance Studies for High-Performance Computing Clusters
Best Practices and Performance Studies for High-Performance Computing ClustersBest Practices and Performance Studies for High-Performance Computing Clusters
Best Practices and Performance Studies for High-Performance Computing ClustersIntel® Software
 
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization ApproachesPragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization ApproachesMarina Kolpakova
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsIntel® Software
 
Parallelization of Coupled Cluster Code with OpenMP
Parallelization of Coupled Cluster Code with OpenMPParallelization of Coupled Cluster Code with OpenMP
Parallelization of Coupled Cluster Code with OpenMPAnil Bohare
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring TechniquesMayada Ghanem
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...Modelon
 

Similar to Peephole optimization techniques (20)

Peephole optimization
Peephole optimization Peephole optimization
Peephole optimization
 
Cse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solutionCse viii-advanced-computer-architectures-06cs81-solution
Cse viii-advanced-computer-architectures-06cs81-solution
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
Instruction compression techniques
Instruction compression techniquesInstruction compression techniques
Instruction compression techniques
 
Automatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole SuperoptimizersAutomatic Generation of Peephole Superoptimizers
Automatic Generation of Peephole Superoptimizers
 
Compiler Optimization-Space Exploration
Compiler Optimization-Space ExplorationCompiler Optimization-Space Exploration
Compiler Optimization-Space Exploration
 
sCode optimization
sCode optimizationsCode optimization
sCode optimization
 
Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide Workshop: Refactoring Legacy PHP: The Complete Guide
Workshop: Refactoring Legacy PHP: The Complete Guide
 
Introduction to Microcontrollers
Introduction to MicrocontrollersIntroduction to Microcontrollers
Introduction to Microcontrollers
 
BAXTER phase 1b
BAXTER phase 1bBAXTER phase 1b
BAXTER phase 1b
 
Code Optimizatoion
Code OptimizatoionCode Optimizatoion
Code Optimizatoion
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Best Practices and Performance Studies for High-Performance Computing Clusters
Best Practices and Performance Studies for High-Performance Computing ClustersBest Practices and Performance Studies for High-Performance Computing Clusters
Best Practices and Performance Studies for High-Performance Computing Clusters
 
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization ApproachesPragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
 
Parallelization of Coupled Cluster Code with OpenMP
Parallelization of Coupled Cluster Code with OpenMPParallelization of Coupled Cluster Code with OpenMP
Parallelization of Coupled Cluster Code with OpenMP
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring Techniques
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...
Multi-core Real-time Simulation of High-Fidelity Vehicle Models using Open St...
 

More from garishma bhatia

More from garishma bhatia (19)

Vm migration techniques
Vm migration techniquesVm migration techniques
Vm migration techniques
 
Denial of service
Denial of serviceDenial of service
Denial of service
 
Iot + cloud
Iot + cloudIot + cloud
Iot + cloud
 
WORKFLOW OF THE PROCESS IN SPM
 WORKFLOW OF THE PROCESS IN SPM WORKFLOW OF THE PROCESS IN SPM
WORKFLOW OF THE PROCESS IN SPM
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
 
BLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGYBLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGY
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problem
 
PRIM'S ALGORITHM
PRIM'S ALGORITHMPRIM'S ALGORITHM
PRIM'S ALGORITHM
 
Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 
Data Algorithms And Analysis
Data Algorithms And AnalysisData Algorithms And Analysis
Data Algorithms And Analysis
 
VEHICLE REGISTRATION PROJECT
VEHICLE REGISTRATION PROJECTVEHICLE REGISTRATION PROJECT
VEHICLE REGISTRATION PROJECT
 
WIFI TECH
WIFI TECHWIFI TECH
WIFI TECH
 
MATCHING GRAPH THEORY
MATCHING GRAPH THEORYMATCHING GRAPH THEORY
MATCHING GRAPH THEORY
 
Garishma se
Garishma seGarishma se
Garishma se
 
Garishma xcs
Garishma xcsGarishma xcs
Garishma xcs
 
Garishma maTHS
Garishma maTHSGarishma maTHS
Garishma maTHS
 
Garishma ec
Garishma ecGarishma ec
Garishma ec
 

Recently uploaded

CCNA: Routing and Switching Fundamentals
CCNA: Routing and Switching FundamentalsCCNA: Routing and Switching Fundamentals
CCNA: Routing and Switching FundamentalsDebabrata Halder
 
BRINDHA G AD21012 SELF INTRODUCTION.pdf
BRINDHA G  AD21012 SELF INTRODUCTION.pdfBRINDHA G  AD21012 SELF INTRODUCTION.pdf
BRINDHA G AD21012 SELF INTRODUCTION.pdfbrindhaaids12
 
Student Challange as Google Developers at NKOCET
Student Challange as Google Developers at NKOCETStudent Challange as Google Developers at NKOCET
Student Challange as Google Developers at NKOCETGDSCNKOCET
 
Metrology Measurements and All units PPT
Metrology Measurements and  All units PPTMetrology Measurements and  All units PPT
Metrology Measurements and All units PPTdinesh babu
 
Eversendai - HSE Performance Management Systems-R1.pptx
Eversendai - HSE Performance Management Systems-R1.pptxEversendai - HSE Performance Management Systems-R1.pptx
Eversendai - HSE Performance Management Systems-R1.pptxADILRASHID54
 
GDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxGDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxAnandMenon54
 
Deluck Technical Works Company Profile.pdf
Deluck Technical Works Company Profile.pdfDeluck Technical Works Company Profile.pdf
Deluck Technical Works Company Profile.pdfartpoa9
 
chap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignchap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignteddymebratie
 
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...IRJET Journal
 
Introduction communication assignmen.pdf
Introduction communication assignmen.pdfIntroduction communication assignmen.pdf
Introduction communication assignmen.pdfKannigaSaraswathyM
 
Sample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeSample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeHarshith A S
 
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...MianHusnainIqbal2
 
Shankar communication assignment no1 .pdf
Shankar communication assignment no1 .pdfShankar communication assignment no1 .pdf
Shankar communication assignment no1 .pdfshankaranarayanan972
 
UNIT I INTRODUCTION TO INTERNET OF THINGS
UNIT I INTRODUCTION TO INTERNET OF THINGSUNIT I INTRODUCTION TO INTERNET OF THINGS
UNIT I INTRODUCTION TO INTERNET OF THINGSbinuvijay1
 
my goal is place in mnc's companies and got good salary
my goal is place in mnc's companies and got good salarymy goal is place in mnc's companies and got good salary
my goal is place in mnc's companies and got good salarymonoarul2004
 
Searching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptxSearching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptxDr. Madhuri Jawale
 
self introduction sri balaji
self introduction sri balajiself introduction sri balaji
self introduction sri balajiSriBalaji891607
 
SATHVIKA A AD21049 SELF INTRODUCTION.pdf
SATHVIKA A AD21049 SELF INTRODUCTION.pdfSATHVIKA A AD21049 SELF INTRODUCTION.pdf
SATHVIKA A AD21049 SELF INTRODUCTION.pdfSathvikaAlagar
 
Critical Literature Review Final -MW.pdf
Critical Literature Review Final -MW.pdfCritical Literature Review Final -MW.pdf
Critical Literature Review Final -MW.pdfMollyWinterbottom
 

Recently uploaded (20)

CCNA: Routing and Switching Fundamentals
CCNA: Routing and Switching FundamentalsCCNA: Routing and Switching Fundamentals
CCNA: Routing and Switching Fundamentals
 
BRINDHA G AD21012 SELF INTRODUCTION.pdf
BRINDHA G  AD21012 SELF INTRODUCTION.pdfBRINDHA G  AD21012 SELF INTRODUCTION.pdf
BRINDHA G AD21012 SELF INTRODUCTION.pdf
 
Student Challange as Google Developers at NKOCET
Student Challange as Google Developers at NKOCETStudent Challange as Google Developers at NKOCET
Student Challange as Google Developers at NKOCET
 
Metrology Measurements and All units PPT
Metrology Measurements and  All units PPTMetrology Measurements and  All units PPT
Metrology Measurements and All units PPT
 
Eversendai - HSE Performance Management Systems-R1.pptx
Eversendai - HSE Performance Management Systems-R1.pptxEversendai - HSE Performance Management Systems-R1.pptx
Eversendai - HSE Performance Management Systems-R1.pptx
 
GDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptxGDSC solution challenge Android ppt.pptx
GDSC solution challenge Android ppt.pptx
 
Deluck Technical Works Company Profile.pdf
Deluck Technical Works Company Profile.pdfDeluck Technical Works Company Profile.pdf
Deluck Technical Works Company Profile.pdf
 
chap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processignchap. 3. lipid deterioration oil and fat processign
chap. 3. lipid deterioration oil and fat processign
 
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...
TUNNELING IN HIMALAYAS WITH NATM METHOD: A SPECIAL REFERENCES TO SUNGAL TUNNE...
 
Introduction communication assignmen.pdf
Introduction communication assignmen.pdfIntroduction communication assignmen.pdf
Introduction communication assignmen.pdf
 
Going Staff
Going StaffGoing Staff
Going Staff
 
Sample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its OutcomeSample Case Study of industry 4.0 and its Outcome
Sample Case Study of industry 4.0 and its Outcome
 
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...
STRETCHABLE STRAIN SENSORS BASED ON POLYPYRROLE AND THERMOPLASTIC POLYURETHAN...
 
Shankar communication assignment no1 .pdf
Shankar communication assignment no1 .pdfShankar communication assignment no1 .pdf
Shankar communication assignment no1 .pdf
 
UNIT I INTRODUCTION TO INTERNET OF THINGS
UNIT I INTRODUCTION TO INTERNET OF THINGSUNIT I INTRODUCTION TO INTERNET OF THINGS
UNIT I INTRODUCTION TO INTERNET OF THINGS
 
my goal is place in mnc's companies and got good salary
my goal is place in mnc's companies and got good salarymy goal is place in mnc's companies and got good salary
my goal is place in mnc's companies and got good salary
 
Searching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptxSearching and Sorting Unit II Part I.pptx
Searching and Sorting Unit II Part I.pptx
 
self introduction sri balaji
self introduction sri balajiself introduction sri balaji
self introduction sri balaji
 
SATHVIKA A AD21049 SELF INTRODUCTION.pdf
SATHVIKA A AD21049 SELF INTRODUCTION.pdfSATHVIKA A AD21049 SELF INTRODUCTION.pdf
SATHVIKA A AD21049 SELF INTRODUCTION.pdf
 
Critical Literature Review Final -MW.pdf
Critical Literature Review Final -MW.pdfCritical Literature Review Final -MW.pdf
Critical Literature Review Final -MW.pdf
 

Peephole optimization techniques

  • 2. CONTENT  What is an Peephole Optimization  Types of Optimization Techniques  What is an Optimization  Replacement Rules  Example  Conclusion  References
  • 3. What is Optimization?  Optimization is the process of transforming a piece of code to make more efficient(either in terms of time or space) without changing its output.  The only difference visible to the user should be that it runs faster and/or consumes less memory.
  • 4. Types of Optimization  Optimization can be categorized broadly into two types :  Machine Independent  Machine dependent
  • 5. Machine-independent Optimization  The compiler takes in the intermediate code and transforms a part of the code that does not involve any CPU registers and/or absolute memory locations.  For example do { item = 10; value = value + item ; } While(value<100); This code involves repeated assignment of the identifier item, which if we put this way:
  • 6. Item = 10; do { value = value + item ; } while(value<100); It should not only save the CPU cycles, but can be used on any processor.
  • 7. Machine-dependent Optimization  Machine-dependent optimization is done after the target code has been generated and when the code is transformed according to the target machine architecture.  It involves CPU registers and may have absolute memory references rather than relative references.  Machine dependent optimizers put efforts to take maximum advantage of memory hierarchy.
  • 8. Peephole Optimization Peephole  Optimization is a kind of optimization performed over a very small set of instructions in a segment of generated code.  The set is called a "peephole" or a "window".  It works by recognizing sets of instructions that can be replaced by shorter or faster sets of instructions.  Goals: - improve performance - reduce memory footprint - reduce code size
  • 9. Replacement Rules  Common techniques applied in peephole optimization:- 1. Constant folding – Evaluate constant sub-expressions in advance. 2. Strength reduction – Replace slow operations with faster equivalents. 3. Null sequences – Delete useless operations. 4. Combine operations – Replace several operations with one equivalent. 5. Algebraic laws – Use algebraic laws to simplify or reorder instructions. 6. Special case instructions – Use instructions designed for special operand cases. 7. Address mode operations – Use address modes to simplify code.