0% found this document useful (0 votes)
3 views9 pages

Compiler Design Un 5

The document outlines the curriculum for the Computer Science and Engineering program at Anna University, detailing subjects across various semesters. It includes a question bank for Compiler Design focusing on code optimization techniques and definitions. Key topics covered include basic blocks, flow graphs, optimization techniques, and various code transformation methods.

Uploaded by

SARDAR HUSSAIN S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Compiler Design Un 5

The document outlines the curriculum for the Computer Science and Engineering program at Anna University, detailing subjects across various semesters. It includes a question bank for Compiler Design focusing on code optimization techniques and definitions. Key topics covered include basic blocks, flow graphs, optimization techniques, and various code transformation methods.

Uploaded by

SARDAR HUSSAIN S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Click on Subject/Paper under Semester to enter.

Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester

4th Semester
- MA3151 MA3251 Computer Organization
1st Semester

2nd Semester

- CS3351 Artificial Intelligence


Engineering Graphics and Machine Learning
Engineering Physics - - CS3491
- GE3251 Foundation of Data
PH3151
Science - CS3352
Database Management
Physics for
Engineering Chemistry System - CS3492
Information Science Data Structure -
- CY3151 - PH3256 CS3301

Basic Electrical and


Algorithms - CS3401
Problem Solving and Electronics Engineering Object Oriented
Python Programming - - BE3251 Programming - CS3391 Introduction to
GE3151 Operating Systems -
Programming in C -
CS3451
CS3251

Computer Networks - Object Oriented


CS3591 Software Engineering
- CCS356
Compiler Design - Human Values and
5th Semester

CS3501 Embedded Systems Ethics - GE3791


7th Semester

8th Semester
6th Semester

and IoT - CS3691


Cryptography and Open Elective 2
Cyber Security - Open Elective-1 Project Work /
CB3491
Open Elective 3 Intership
Distributed Computing Elective-3
- CS3551 Open Elective 4
Elective-4
Elective 1
Management Elective
Elective-5
Elective 2
Elective-6
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to
enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering
www.BrainKart.com

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BE- Computer Science and Engineering

Anna University Regulation: 2021

CS3501- COMPILER DESIGN

III Year/V Semester

Question Bank

Unit – V Code Optimization

Prepared By,

Mrs.J.SWEETLINE ARPUTHAM, AP/CSE

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com
4931_GRACE College of Engineering,Thoothukudi

UNIT V
CODE OPTIMIZATION
1. What are basic blocks?

A sequence of consecutive statements which may be entered only at the beginning and when
entered are executed in sequence without halt or possibility of branch, are called basic blocks

2. What do you mean by copy propagation?


After the assignment of one variable to another, a reference to one variable may be
replaced with the value of the other variable.
If w := x appears in a block, all subsequent uses of w can be replaced with uses of x.
Before After
b := z + y b := z + y
a := b a := b
x := 2 * b x := 2 * a

3. What is a flow graph?

The basic block and their successor relationships shown by a directed graph is called a flow
graph. The nodes of a flow graph are the basic blocks.

4. Write the three address code sequence for the assignment statement.
d:=(a-b)+(a-c)+(a-c) t1=a-b
t2=a-c t3=t1+t2 t4=t3+t2
d=t4

5. What is meant by peephole optimization?


Peephole optimization is a technique used in many compliers, in connection with the
optimization of either intermediate or object code. It is really an attempt to overcome the
difficulties encountered in syntax directed generation of code.

6. What are the issues in the design of code generators?


Input to the code generator Target programs
Memory management Instruction selection Register allocation
Choice of evaluation order Approaches to code generation

7. What is register descriptor and address descriptor?


A register descriptor keeps track of what is currently in each register.
An address descriptor keeps track of the location where the current value of the name can be
found at run time.

8. Define DAG.
A DAG for a basic block is a directed acyclic graph with the following labels on nodes:
Leaves are labeled by unique identifiers, either variable names or constants.
Interior nodes are labeled by an operator symbol.
Nodes are also optionally given a sequence of identifiers for labels.

CS3501_CD

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com
4931_GRACE College of Engineering,Thoothukudi

9. Name the techniques in Loop optimization.


Code Motion, Induction variable elimination, Reduction in strength

10. Define local optimization.


The optimization performed within a block of code is called a local optimization.

11. Define constant folding.


Deducing at compile time that the value of an expression is a constant and using the constant
instead is known as constant folding.

12. What is code motion?


Code motion is an important modification that decreases the amount of code in a loop.

13. What are the properties of optimizing compilers?


Transformation must preserve the meaning of programs. Transformation must, on the average,
speed up the programs by a measurable amount
A Transformation must be worth the effort.
The source code should be such that it should produce minimum amount of target code.
There should not be any unreachable code.
Dead code should be completely removed from source language.

14. Define Local transformation & Global Transformation.


A transformation of a program is called Local, if it can be performed by looking only at the
statements in a basic block otherwise it is called global.

15. What is meant by Common Sub-expressions?


An occurrence of an expression E is called a common sub-expression, if E was previously
computed, and the values of variables in E have not changed since the previous computation.

16. What is meant by Dead Code? Or Define Live variable?


A variable is live at a point in a program if its value can be used subsequently otherwise, it is
dead at that point. The statement that computes values that never get used is known Dead code or
useless code.

17. What is meant by Reduction in strength?


Reduction in strength is the one which replaces an expensive operation by a cheaper one such as
a multiplication by an addition

18. What is meant by loop invariant computation?


An expression that yields the same result independent of the number of times the loop is
executed is known as loop invariant computation.

19. When is a flow graph reducible?


A flow graph is reducible if and only if we can partition the edges into two disjoint groups often
called the forward edges and back edges.

CS3501_CD

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com
4931_GRACE College of Engineering,Thoothukudi

20. What is induction variable?


A variable is called an induction variable of a loop if every time the variable changes values, it is
incremented or decremented by some constant.

CS3501_CD

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
www.BrainKart.com
4931_GRACE College of Engineering,Thoothukudi

UNIT V
PART B
1. Explain briefly about the principal sources of optimization
2. Explain in detail about optimization of basic blocks.
3. Construct the DAG for the following Basic block & explain it.
1. t1: = 4 * i
2. t2:= a [t1]
3. t3: = 4 * i
4. t4:= b [t3]
5. t5:=t2*t4
6. t6:=Prod+t5
7. Prod:=t6
8. t7:=i+1
9. i:= t7
10. if i<= 20 goto (1).
4. Discuss the following in detail
(i)Semantic Preserving transformation
(ii)Global Common subexpression
5. Write about the following in detail
(i)copy propagation (ii)Dead code Elimination
(iii)code motion
6. Analyze Peephole optimization with suitable
examples
7. Discuss in detail about the Use of Algebraic Identities.
8. Describe in detail about the flow of control optimization.
9. Describe about induction variable and end reduction in strength
10. Describe the efficient data flow algorithms in
detail.
11. Give an example to identify the dead code in the DAG.
12. Describe the representation of array using DAG with example.
13. Create DAG and three – address code for the following program.
i = 1; s = 0;
while ( i<= 10)
{
s = s+ a[i] [i];
i = i + 1;
}

CS3501_CD

https://play.google.com/store/apps/details?id=info.therithal.brainkart.annauniversitynotes&hl=en_IN
Click on Subject/Paper under Semester to enter.
Environmental Sciences
Professional English and Sustainability -
Professional English - - II - HS3252 Discrete Mathematics GE3451
I - HS3152 - MA3354
Statistics and Theory of Computation
Matrices and Calculus Numerical Methods - Digital Principles and - CS3452
3rd Semester

4th Semester
- MA3151 MA3251 Computer Organization
1st Semester

2nd Semester

- CS3351 Artificial Intelligence


Engineering Graphics and Machine Learning
Engineering Physics - - CS3491
- GE3251 Foundation of Data
PH3151
Science - CS3352
Database Management
Physics for
Engineering Chemistry System - CS3492
Information Science Data Structure -
- CY3151 - PH3256 CS3301

Basic Electrical and


Algorithms - CS3401
Problem Solving and Electronics Engineering Object Oriented
Python Programming - - BE3251 Programming - CS3391 Introduction to
GE3151 Operating Systems -
Programming in C -
CS3451
CS3251

Computer Networks - Object Oriented


CS3591 Software Engineering
- CCS356
Compiler Design - Human Values and
5th Semester

CS3501 Embedded Systems Ethics - GE3791


7th Semester

8th Semester
6th Semester

and IoT - CS3691


Cryptography and Open Elective 2
Cyber Security - Open Elective-1 Project Work /
CB3491
Open Elective 3 Intership
Distributed Computing Elective-3
- CS3551 Open Elective 4
Elective-4
Elective 1
Management Elective
Elective-5
Elective 2
Elective-6
All Computer Engg Subjects - [ B.E., M.E., ] (Click on Subjects to
enter)
Programming in C Computer Networks Operating Systems
Programming and Data Programming and Data Problem Solving and Python
Structures I Structure II Programming
Database Management Systems Computer Architecture Analog and Digital
Communication
Design and Analysis of Microprocessors and Object Oriented Analysis
Algorithms Microcontrollers and Design
Software Engineering Discrete Mathematics Internet Programming
Theory of Computation Computer Graphics Distributed Systems
Mobile Computing Compiler Design Digital Signal Processing
Artificial Intelligence Software Testing Grid and Cloud Computing
Data Ware Housing and Data Cryptography and Resource Management
Mining Network Security Techniques
Service Oriented Architecture Embedded and Real Time Multi - Core Architectures
Systems and Programming
Probability and Queueing Theory Physics for Information Transforms and Partial
Science Differential Equations
Technical English Engineering Physics Engineering Chemistry
Engineering Graphics Total Quality Professional Ethics in
Management Engineering
Basic Electrical and Electronics Problem Solving and Environmental Science and
and Measurement Engineering Python Programming Engineering

You might also like