SlideShare a Scribd company logo
1 of 14
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

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
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generatorsanchi29
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design) Tasif Tanzim
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture NotesFellowBuddy.com
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow GraphsJenny Galino
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler designSudip Singh
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical AnalyzerArchana Gopinath
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler designKuppusamy P
 
weak slot and filler structure
weak slot and filler structureweak slot and filler structure
weak slot and filler structureAmey Kerkar
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in CompilerAkhil Kaushik
 

What's hot (20)

Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
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
 
Intermediate code generator
Intermediate code generatorIntermediate code generator
Intermediate code generator
 
Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)   Intermediate code generation (Compiler Design)
Intermediate code generation (Compiler Design)
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Dynamic Itemset Counting
Dynamic Itemset CountingDynamic Itemset Counting
Dynamic Itemset Counting
 
Basic Blocks and Flow Graphs
Basic Blocks and Flow GraphsBasic Blocks and Flow Graphs
Basic Blocks and Flow Graphs
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Language for specifying lexical Analyzer
Language for specifying lexical AnalyzerLanguage for specifying lexical Analyzer
Language for specifying lexical Analyzer
 
Code optimization in compiler design
Code optimization in compiler designCode optimization in compiler design
Code optimization in compiler design
 
weak slot and filler structure
weak slot and filler structureweak slot and filler structure
weak slot and filler structure
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 

Similar to OPTIMIZATION OF BASIC BLOCKS THROUGH ALGEBRAIC AND COMMON SUBEXPRESSION ELIMINATION

CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptssuser0be977
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksMohammad Vaseem Akaram
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4Dr.YNM
 
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.pptxTaoqeerRajput
 
Constructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfConstructors & Destructors [Compatibility Mode].pdf
Constructors & Destructors [Compatibility Mode].pdfLadallaRajKumar
 
Basic blocks - compiler design
Basic blocks - compiler designBasic blocks - compiler design
Basic blocks - compiler designhmnasim15
 
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 blocksShabeen 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.pdfhasan752746
 

Similar to OPTIMIZATION OF BASIC BLOCKS THROUGH ALGEBRAIC AND COMMON SUBEXPRESSION ELIMINATION (20)

CS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.pptCS540-2-lecture11 - Copy.ppt
CS540-2-lecture11 - Copy.ppt
 
Code Optimization.ppt
Code Optimization.pptCode Optimization.ppt
Code Optimization.ppt
 
Directed Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocksDirected Acyclic Graph Representation of basic blocks
Directed Acyclic Graph Representation of basic blocks
 
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
 
Basic blocks - compiler design
Basic blocks - compiler designBasic blocks - compiler design
Basic blocks - compiler design
 
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

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

OPTIMIZATION OF BASIC BLOCKS THROUGH ALGEBRAIC AND COMMON SUBEXPRESSION ELIMINATION

  • 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