SlideShare a Scribd company logo
OPTIMIZATION OF BASIC
BLOCKS
ISHWARYA LAKSHMI.TK
BP150516
3/14/2017 1
OPTIMIZATION OF BASIC BLOCKS
• The code improving transformations for basic
blocks included structure - preserving
transformations, such as common sub
expression elimination and dead-code
elimination, and algebraic transformation such
as reduction in strength.
3/14/2017 2
Cont …
• Many of the structure-preventing
transformation can be implemented by
constructing a dag or a basic blocks
• Recall that there is a node in the dag for each
of the initial values of the variables appearing
in the basic block, and there is a node n
associated with each statement s within the
block.
3/14/2017 3
Cont …
• Node n is labeled by the operator applied at s,
and also attached to n is the list of variables for
which it is the last definition within the block.
• If any node’s values are live on exit from the
block, these are the output nodes.
3/14/2017 4
Cont …
• Common sub expressions can be detected by
noticing, as a new node m is about to a added,
whether there is an existing node n with the
same children, in the same order, and with the
same operator. If so, n computes the same
value as m and may be used in its place.
3/14/2017 5
A dag for the basic block
• a = b + c
• b = a - d
• c = b + c
• d = a – d
• a = b + c
• d = a - d
• c = d + c3/14/2017 6
Cont …
• a = b + c
• b = b - d
• c = c + d
• e = b + c
3/14/2017 7
The Use of Algebraic Identities
• Algebraic identities another important class of
optimization on basic blocks.
• The simple algebraic transformations that one
might try during optimization.
• For examples apply arithmetic identities, such
as
• x + 0 = 0 + x = x
• x – 0 = x
• x * 1 = 1 * x = x
• x / 1 =x
3/14/2017 8
Cont …
• Another class of algebraic optimization
includes reduction in strength, that is,
replacing a more expensive operator by a
cheaper one as in
• x * * 2 = x * x
• 2.0 * x = x + x
• x / 2 = x * 0.5
3/14/2017 9
Cont …
• Evaluate constant expressions at compile time
and replace the constant expressions by their
values.
– 2*3.14 => 6.28
• The dag-construction process can help us
apply these and other more general algebraic
transformations such as commutative and
associative
3/14/2017 10
Cont …
• For example, suppose * is commutative ; that
is, x * y = y * x.
• Before create a new node labeled * with left
child m and right child n, check whether such
a node already exists, then check for a node
having operator *, let child n and right child m.
3/14/2017 11
Cont …
• The relational operators <=, >=, <, >, =, and !=
sometimes generate unexpected common sub
expressions.
• For example
• X – y and x > y
3/14/2017 12
Cont …
• Associative laws may also be applied to
expose common sub expressions.
• For example
• a = b + c
• e = c + d +b
Intermediate node generated
• a = b + c
• t = c + d -> a = b + c
• e = t + b -> e = a + d
3/14/2017 13
Cont …
• Computer arithmetic does not always the
algebraic identities o mathematics.
• For example, the standard for Fortran77 states
that a integrity of parentheses is not violated.
• Thus, a compiler may evaluate x * y – x * z as
x*(y-z) but it may not evaluate a + ( b – c ) as
( a + b ) - c.
3/14/2017 14

More Related Content

What's hot

Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
Meghaj Mallick
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
Eelco Visser
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
Kuppusamy P
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
sanchi29
 
Code generator
Code generatorCode generator
Code generatorTech_MX
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
Akshaya Arunan
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
indhu mathi
 
Access to non local names
Access to non local namesAccess to non local names
Access to non local namesVarsha Kumar
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
Akhil Kaushik
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
Rajkumar R
 
Heap Management
Heap ManagementHeap Management
Heap Management
Jenny Galino
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
RamchandraRegmi
 
Basic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler ConstructionBasic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler Construction
Muhammad Haroon
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
Jenny Galino
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
Akshaya Arunan
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
Dattatray Gandhmal
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
Mazin Alwaaly
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
Kuppusamy P
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
Temesgen Molla
 

What's hot (20)

Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Code generator
Code generatorCode generator
Code generator
 
Bottom up parser
Bottom up parserBottom up parser
Bottom up parser
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Access to non local names
Access to non local namesAccess to non local names
Access to non local names
 
Compiler Design Basics
Compiler Design BasicsCompiler Design Basics
Compiler Design Basics
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
 
Heap Management
Heap ManagementHeap Management
Heap Management
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Basic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler ConstructionBasic blocks and flow graph in Compiler Construction
Basic blocks and flow graph in Compiler Construction
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Input-Buffering
Input-BufferingInput-Buffering
Input-Buffering
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 

Similar to Optimization of basic blocks

Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
JohnSamuel280314
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
ssuser0be977
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Maaz609108
 
c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444
PurvaShyama
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
Dr.YNM
 
Module-2_ML.pdf
Module-2_ML.pdfModule-2_ML.pdf
Module-2_ML.pdf
ArpanSoni16
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01Hemant Jha
 
WEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptxWEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptx
TaoqeerRajput
 
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfConstructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdf
LadallaRajKumar
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
RAJ KUMAR
 
The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
Shabeen Taj
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
Civil Estimating Methods.pdf
Civil Estimating Methods.pdfCivil Estimating Methods.pdf
Civil Estimating Methods.pdf
hasan752746
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
shashikant pabari
 

Similar to Optimization of basic blocks (20)

Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
 
CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
 
c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444c programming L-1.pdf43333333544444444444444444444
c programming L-1.pdf43333333544444444444444444444
 
Operators
OperatorsOperators
Operators
 
Stoop 300-block optimizationinvw
Stoop 300-block optimizationinvwStoop 300-block optimizationinvw
Stoop 300-block optimizationinvw
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
 
Module-2_ML.pdf
Module-2_ML.pdfModule-2_ML.pdf
Module-2_ML.pdf
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
 
WEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptxWEEK 4- DLD-GateLvelMinimization.pptx
WEEK 4- DLD-GateLvelMinimization.pptx
 
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfConstructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdf
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
 
The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
L7 pointers
L7 pointersL7 pointers
L7 pointers
 
106da session5 c++
106da session5 c++106da session5 c++
106da session5 c++
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Civil Estimating Methods.pdf
Civil Estimating Methods.pdfCivil Estimating Methods.pdf
Civil Estimating Methods.pdf
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

Optimization of basic blocks

  • 1. OPTIMIZATION OF BASIC BLOCKS ISHWARYA LAKSHMI.TK BP150516 3/14/2017 1
  • 2. OPTIMIZATION OF BASIC BLOCKS • The code improving transformations for basic blocks included structure - preserving transformations, such as common sub expression elimination and dead-code elimination, and algebraic transformation such as reduction in strength. 3/14/2017 2
  • 3. Cont … • Many of the structure-preventing transformation can be implemented by constructing a dag or a basic blocks • Recall that there is a node in the dag for each of the initial values of the variables appearing in the basic block, and there is a node n associated with each statement s within the block. 3/14/2017 3
  • 4. Cont … • Node n is labeled by the operator applied at s, and also attached to n is the list of variables for which it is the last definition within the block. • If any node’s values are live on exit from the block, these are the output nodes. 3/14/2017 4
  • 5. Cont … • Common sub expressions can be detected by noticing, as a new node m is about to a added, whether there is an existing node n with the same children, in the same order, and with the same operator. If so, n computes the same value as m and may be used in its place. 3/14/2017 5
  • 6. A dag for the basic block • a = b + c • b = a - d • c = b + c • d = a – d • a = b + c • d = a - d • c = d + c3/14/2017 6
  • 7. Cont … • a = b + c • b = b - d • c = c + d • e = b + c 3/14/2017 7
  • 8. The Use of Algebraic Identities • Algebraic identities another important class of optimization on basic blocks. • The simple algebraic transformations that one might try during optimization. • For examples apply arithmetic identities, such as • x + 0 = 0 + x = x • x – 0 = x • x * 1 = 1 * x = x • x / 1 =x 3/14/2017 8
  • 9. Cont … • Another class of algebraic optimization includes reduction in strength, that is, replacing a more expensive operator by a cheaper one as in • x * * 2 = x * x • 2.0 * x = x + x • x / 2 = x * 0.5 3/14/2017 9
  • 10. Cont … • Evaluate constant expressions at compile time and replace the constant expressions by their values. – 2*3.14 => 6.28 • The dag-construction process can help us apply these and other more general algebraic transformations such as commutative and associative 3/14/2017 10
  • 11. Cont … • For example, suppose * is commutative ; that is, x * y = y * x. • Before create a new node labeled * with left child m and right child n, check whether such a node already exists, then check for a node having operator *, let child n and right child m. 3/14/2017 11
  • 12. Cont … • The relational operators <=, >=, <, >, =, and != sometimes generate unexpected common sub expressions. • For example • X – y and x > y 3/14/2017 12
  • 13. Cont … • Associative laws may also be applied to expose common sub expressions. • For example • a = b + c • e = c + d +b Intermediate node generated • a = b + c • t = c + d -> a = b + c • e = t + b -> e = a + d 3/14/2017 13
  • 14. Cont … • Computer arithmetic does not always the algebraic identities o mathematics. • For example, the standard for Fortran77 states that a integrity of parentheses is not violated. • Thus, a compiler may evaluate x * y – x * z as x*(y-z) but it may not evaluate a + ( b – c ) as ( a + b ) - c. 3/14/2017 14