Compiler Design Un 5
Compiler Design Un 5
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
8th Semester
6th Semester
Question Bank
Prepared By,
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
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
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
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
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
8th Semester
6th Semester