SlideShare a Scribd company logo
8
Most read
9
Most read
11
Most read
Peephole Optimization Techniques
In Compiler Design
Anul Chaudhary
131CC00304
Contents
Example
Replacement Rules
What is an Peephole Optimization
Types of Optimization Techniques
What is an Optimization
2
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 or side-effects. The only difference
visible to the code’s user should be that it runs
faster and/or consumes less memory. It is really
a misnomer that the name implies you are
finding an “optimal” solution— in truth,
optimization aims to improve, not perfect, the
result.
Types of Optimization
Optimization can be categorized broadly into two types :
1. Machine Independent
2. 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.
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.
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
Replacement Rules
Common techniques applied in peephole optimization:-
 Constant folding – Evaluate constant sub-expressions in
advance.
 Strength reduction– Replace slow operations with faster
equivalents.
 Null sequences – Delete useless operations.
 Combine operations – Replace several operations with one
equivalent.
 Algebraic laws – Use algebraic laws to simplify or reorder
instructions.
 Special case instructions – Use instructions designed for
special operand cases.
 Address mode operations – Use address modes to simplify
code.
Examples
Peephole optimization techniques in compiler design
Fall 2011“Advanced Compiler Techniques”
References
 https://en.wikipedia.org/wiki/Peephole_optimization
 http://www.iosrjournals.org/iosr-jce/papers/Vol9-
Issue4/N0948086.pdf?id=255
 https://class.coursera.org/compilers/lecture/76
Thank You

More Related Content

What's hot (20)

PPTX
Peephole Optimization
United International University
 
PDF
Code optimization in compiler design
Kuppusamy P
 
PPTX
System software - macro expansion,nested macro calls
SARASWATHI S
 
PPTX
Structure of the compiler
Sudhaa Ravi
 
PPTX
Specification-of-tokens
Dattatray Gandhmal
 
PPTX
Loop optimization
Vivek Gandhi
 
PPT
17. Recovery System in DBMS
koolkampus
 
PPTX
Principle source of optimazation
Siva Sathya
 
PPTX
Code generation
Aparna Nayak
 
PDF
Parse Tree
A. S. M. Shafi
 
PPTX
Heap Management
Jenny Galino
 
PPT
16. Concurrency Control in DBMS
koolkampus
 
PPTX
Loops in flow
indhu mathi
 
PPTX
Basic Blocks and Flow Graphs
Jenny Galino
 
PPTX
Lexical analyzer generator lex
Anusuya123
 
PPTX
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
PPTX
Principal Sources of Optimization in compiler design
LogsAk
 
PPTX
Recognition-of-tokens
Dattatray Gandhmal
 
PPTX
Context free grammar
Mohammad Ilyas Malik
 
PPTX
Three Address code
Pooja Dixit
 
Peephole Optimization
United International University
 
Code optimization in compiler design
Kuppusamy P
 
System software - macro expansion,nested macro calls
SARASWATHI S
 
Structure of the compiler
Sudhaa Ravi
 
Specification-of-tokens
Dattatray Gandhmal
 
Loop optimization
Vivek Gandhi
 
17. Recovery System in DBMS
koolkampus
 
Principle source of optimazation
Siva Sathya
 
Code generation
Aparna Nayak
 
Parse Tree
A. S. M. Shafi
 
Heap Management
Jenny Galino
 
16. Concurrency Control in DBMS
koolkampus
 
Loops in flow
indhu mathi
 
Basic Blocks and Flow Graphs
Jenny Galino
 
Lexical analyzer generator lex
Anusuya123
 
Unit iv(simple code generator)
Kalaimathi Vijayakumar
 
Principal Sources of Optimization in compiler design
LogsAk
 
Recognition-of-tokens
Dattatray Gandhmal
 
Context free grammar
Mohammad Ilyas Malik
 
Three Address code
Pooja Dixit
 

Viewers also liked (7)

PPT
0015.register allocation-graph-coloring
sean chen
 
PPTX
Role-of-lexical-analysis
Dattatray Gandhmal
 
PPTX
Code optimization
veena venugopal
 
PPT
Code Optimization
guest9f8315
 
PPTX
Two pass Assembler
Satyamevjayte Haxor
 
PPTX
Three address code In Compiler Design
Shine Raj
 
PPT
Lexical analyzer
Ashwini Sonawane
 
0015.register allocation-graph-coloring
sean chen
 
Role-of-lexical-analysis
Dattatray Gandhmal
 
Code optimization
veena venugopal
 
Code Optimization
guest9f8315
 
Two pass Assembler
Satyamevjayte Haxor
 
Three address code In Compiler Design
Shine Raj
 
Lexical analyzer
Ashwini Sonawane
 
Ad

Similar to Peephole optimization techniques in compiler design (20)

PPTX
Peephole optimization techniques
garishma bhatia
 
PPTX
Peephole Optimization
Meghaj Mallick
 
PPTX
Code optimization
veena venugopal
 
PPTX
Peephole optimization
Mvidhya9
 
PDF
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Marina Kolpakova
 
PDF
Optimization
Royalzig Luxury Furniture
 
PDF
Optimization
Royalzig Luxury Furniture
 
PPTX
Code optmize.pptx which is related to coding
vamami6395
 
PPTX
UNIT V - Compiler Design notes power point presentation
KowsalyaG17
 
PPTX
Code Optimization In Code Generator In Compiler Design Subject.pptx
22r11a05j2
 
PPTX
Compiler optimization techniques
Hardik Devani
 
PDF
SPCC_Sem6_Chapter 6_Code Optimization part
NiramayKolalle
 
PPTX
Downlaod Wise Registry Cleaner Pro Crack
tomcross837
 
PPTX
Autodesk CFD Ultimate Crack Latest Version
losbeten
 
PPTX
Download RarmaRadio Pro Crack Latest [2025]
wreeen464
 
PPTX
Code_Optimization_Compiler_Design software .pptx
AmishaKumari97
 
PPTX
NCH VideoPad Pro Cracked Version Download
jasperjhin57
 
PPTX
Latest TreeSize Professional 9 Crack Download
bentenkhan340
 
PPTX
PowerDirector Activated Full Tested Download
tomveren
 
PPTX
Download Artweaver Plus Cracked Version Free
adomalex314
 
Peephole optimization techniques
garishma bhatia
 
Peephole Optimization
Meghaj Mallick
 
Code optimization
veena venugopal
 
Peephole optimization
Mvidhya9
 
Pragmatic Optimization in Modern Programming - Ordering Optimization Approaches
Marina Kolpakova
 
Code optmize.pptx which is related to coding
vamami6395
 
UNIT V - Compiler Design notes power point presentation
KowsalyaG17
 
Code Optimization In Code Generator In Compiler Design Subject.pptx
22r11a05j2
 
Compiler optimization techniques
Hardik Devani
 
SPCC_Sem6_Chapter 6_Code Optimization part
NiramayKolalle
 
Downlaod Wise Registry Cleaner Pro Crack
tomcross837
 
Autodesk CFD Ultimate Crack Latest Version
losbeten
 
Download RarmaRadio Pro Crack Latest [2025]
wreeen464
 
Code_Optimization_Compiler_Design software .pptx
AmishaKumari97
 
NCH VideoPad Pro Cracked Version Download
jasperjhin57
 
Latest TreeSize Professional 9 Crack Download
bentenkhan340
 
PowerDirector Activated Full Tested Download
tomveren
 
Download Artweaver Plus Cracked Version Free
adomalex314
 
Ad

Recently uploaded (20)

PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
community health nursing question paper 2.pdf
Prince kumar
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 

Peephole optimization techniques in compiler design