SlideShare a Scribd company logo
3
Most read
5
Most read
6
Most read
Seminar
on
Principles of Compiler Design
“Directed Acyclic Graph Representation of basic blocks”
Presented By:
Mohd Vaseem Akaram
ID: 17370206
Presented To:
Ms. Nivetha Ma'am
Dept of Computer Science
• In compiler design, a directed acyclic graph (DAG) is on abstract syntax tree(AST) with a
unique node for each value.
OR
• A directed acyclic graph(DAG) is a directed graph that contains no cycles.
Definitions
• DAG is useful data structure for implementing transformation on basic blocks.
• A basic block can optimized by the construction of DAG.
• A DAG can be constructed for a block and certain transformations such as common sub-
expression elimination and dead code elimination applied for performance the local
optimization.
• To apply the transformation on basic block, a DAG is constructed from three address
code.
Use of DAG for optimizing basic blocks
The DAG is Used In:
• Determine the common sub expression (Expression computed more than one).
• Determine which names are used in block and computed outside the block.
• Determine which statements of the block could their computed value.
Applications of DAG
Rule 1: In a DAG
• Leaf node represent identifiers, names or constants.
• Interior node represent operators.
Rule 2:
• While constructing DAG, there is a check made to find if there is on existing
node with the same children. A new node is created only when such a node
doesn't exist This action allow us to detect common sub expression and
eliminate the re computation of the same.
Rule 3:
• The assignment of the from x:= must not be performed until and unless it is a
must.
Rules of the constructing DAG
• Problem 1:
Construct DAG for the given expression
(a+b) * (a+b+c)
Solution: Three address code for the given expression.
t1=a+b
t2=t1+c
t3=t1*t2
The DAG is:
Problems
• From the constructed DAG, we observed that the common sub expression (a+b) is
translated into a single node in the DAG. The computation is carried out only
once and stored in the identifier t1 and reused later.
• This illustrates how the DAG construction scheme identifies the common sub
expression and helps in elimination its re-computation later.
Explanation
• Problem 2:
Construct DAG for the given expression
(((a+a) + (a+a))+ ((a+a) + (a+a)))
Solution: DAG for this Expression is-
Problem 3:
Construct DAG for the given expression
a = b * c
d = b
e = d * c
b = e
f = b + c
g = f + d
Solution:
Step 1: Step 2:
Step 3: Step 4:
Step 5: Step 6:
Thank You! 

More Related Content

PPT
Intermediate code generation (Compiler Design)
PPTX
Code generation
PPT
1.Role lexical Analyzer
PPTX
Logic Gates
PDF
PPT
SHA 1 Algorithm.ppt
PDF
Target language in compiler design
PDF
Support Vector Machines ( SVM )
Intermediate code generation (Compiler Design)
Code generation
1.Role lexical Analyzer
Logic Gates
SHA 1 Algorithm.ppt
Target language in compiler design
Support Vector Machines ( SVM )

What's hot (20)

PPTX
Dag representation of basic blocks
PPT
Type Checking(Compiler Design) #ShareThisIfYouLike
PDF
Syntax directed translation
PDF
Symbol table in compiler Design
DOC
Dma transfer
PPTX
Three address code In Compiler Design
PPTX
The dag representation of basic blocks
PPTX
Compiler Chapter 1
PPT
Disk scheduling
PPTX
Design of a two pass assembler
PPTX
A Role of Lexical Analyzer
PPT
13. Query Processing in DBMS
PPTX
Single source Shortest path algorithm with example
PPT
Top down parsing
PPTX
Deadlock ppt
PDF
Interconnection Network
PDF
Code optimization in compiler design
PPTX
Loop optimization
PPT
Unit 1 chapter 1 Design and Analysis of Algorithms
PPTX
Indexing structure for files
Dag representation of basic blocks
Type Checking(Compiler Design) #ShareThisIfYouLike
Syntax directed translation
Symbol table in compiler Design
Dma transfer
Three address code In Compiler Design
The dag representation of basic blocks
Compiler Chapter 1
Disk scheduling
Design of a two pass assembler
A Role of Lexical Analyzer
13. Query Processing in DBMS
Single source Shortest path algorithm with example
Top down parsing
Deadlock ppt
Interconnection Network
Code optimization in compiler design
Loop optimization
Unit 1 chapter 1 Design and Analysis of Algorithms
Indexing structure for files
Ad

Similar to Directed Acyclic Graph Representation of basic blocks (20)

PDF
Code optimization lecture
PPT
unit-5.pptvshvshshhshsjjsjshhshshshhshsj
PDF
24-02-18 Rejender pratap.pdf
PPTX
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
PPTX
UNIT V - Compiler Design notes power point presentation
PPTX
Principal Sources of Optimization in compiler design
PDF
Unit- 2_my1.pdf jbvjwe vbeijv dv d d d kjd k
PDF
Intermediate code generation in Compiler Design
PDF
Reduction
PPTX
Optimization of basic blocks
PPTX
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
PDF
Gsp 125 final exam guide
PDF
A Novel Framework and Policies for On-line Block of Cores Allotment for Multi...
PPTX
GBM package in r
PPTX
C Programming : Arrays and Functions
PDF
GSP 125 Final Exam Guide
PDF
Enscape 3D 3.6.6 License Key Crack Full Version
PDF
Wondershare UniConverter Crack Download Latest 2025
PPT
Code_generatio.lk,jhgfdcxzcvgfhjkmnjhgfcxvfghjmh
PDF
Wondershare Filmora Crack 12.0.10 With Latest 2025
Code optimization lecture
unit-5.pptvshvshshhshsjjsjshhshshshhshsj
24-02-18 Rejender pratap.pdf
Vlsiphysicaldesignautomationonpartitioning 120219012744-phpapp01
UNIT V - Compiler Design notes power point presentation
Principal Sources of Optimization in compiler design
Unit- 2_my1.pdf jbvjwe vbeijv dv d d d kjd k
Intermediate code generation in Compiler Design
Reduction
Optimization of basic blocks
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Gsp 125 final exam guide
A Novel Framework and Policies for On-line Block of Cores Allotment for Multi...
GBM package in r
C Programming : Arrays and Functions
GSP 125 Final Exam Guide
Enscape 3D 3.6.6 License Key Crack Full Version
Wondershare UniConverter Crack Download Latest 2025
Code_generatio.lk,jhgfdcxzcvgfhjkmnjhgfcxvfghjmh
Wondershare Filmora Crack 12.0.10 With Latest 2025
Ad

Recently uploaded (20)

PPTX
Current and future trends in Computer Vision.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Construction Project Organization Group 2.pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Categorization of Factors Affecting Classification Algorithms Selection
DOCX
573137875-Attendance-Management-System-original
PPTX
Sustainable Sites - Green Building Construction
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
additive manufacturing of ss316l using mig welding
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPT
Mechanical Engineering MATERIALS Selection
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPT
introduction to datamining and warehousing
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
PPT on Performance Review to get promotions
PPTX
Geodesy 1.pptx...............................................
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Current and future trends in Computer Vision.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Construction Project Organization Group 2.pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Categorization of Factors Affecting Classification Algorithms Selection
573137875-Attendance-Management-System-original
Sustainable Sites - Green Building Construction
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
additive manufacturing of ss316l using mig welding
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Mechanical Engineering MATERIALS Selection
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
introduction to datamining and warehousing
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPT on Performance Review to get promotions
Geodesy 1.pptx...............................................
Fundamentals of Mechanical Engineering.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx

Directed Acyclic Graph Representation of basic blocks

  • 1. Seminar on Principles of Compiler Design “Directed Acyclic Graph Representation of basic blocks” Presented By: Mohd Vaseem Akaram ID: 17370206 Presented To: Ms. Nivetha Ma'am Dept of Computer Science
  • 2. • In compiler design, a directed acyclic graph (DAG) is on abstract syntax tree(AST) with a unique node for each value. OR • A directed acyclic graph(DAG) is a directed graph that contains no cycles. Definitions
  • 3. • DAG is useful data structure for implementing transformation on basic blocks. • A basic block can optimized by the construction of DAG. • A DAG can be constructed for a block and certain transformations such as common sub- expression elimination and dead code elimination applied for performance the local optimization. • To apply the transformation on basic block, a DAG is constructed from three address code. Use of DAG for optimizing basic blocks
  • 4. The DAG is Used In: • Determine the common sub expression (Expression computed more than one). • Determine which names are used in block and computed outside the block. • Determine which statements of the block could their computed value. Applications of DAG
  • 5. Rule 1: In a DAG • Leaf node represent identifiers, names or constants. • Interior node represent operators. Rule 2: • While constructing DAG, there is a check made to find if there is on existing node with the same children. A new node is created only when such a node doesn't exist This action allow us to detect common sub expression and eliminate the re computation of the same. Rule 3: • The assignment of the from x:= must not be performed until and unless it is a must. Rules of the constructing DAG
  • 6. • Problem 1: Construct DAG for the given expression (a+b) * (a+b+c) Solution: Three address code for the given expression. t1=a+b t2=t1+c t3=t1*t2 The DAG is: Problems
  • 7. • From the constructed DAG, we observed that the common sub expression (a+b) is translated into a single node in the DAG. The computation is carried out only once and stored in the identifier t1 and reused later. • This illustrates how the DAG construction scheme identifies the common sub expression and helps in elimination its re-computation later. Explanation
  • 8. • Problem 2: Construct DAG for the given expression (((a+a) + (a+a))+ ((a+a) + (a+a))) Solution: DAG for this Expression is-
  • 9. Problem 3: Construct DAG for the given expression a = b * c d = b e = d * c b = e f = b + c g = f + d Solution: Step 1: Step 2:
  • 10. Step 3: Step 4: Step 5: Step 6: